private class prgclm { double wp; double ln; int cnt; } public void getChgDetail(){ prgclm [] p = new prgclm[cnt]; for(int j=0;j<cnt;j++) { p[j] = new prgclm(); } String detail = "SELECT * FROM mrladf "+ " WHERE pf_la_no = '"+laNo+"'"+ " AND pf_supl_typ = '"+suplTyp+"'"+ " AND pf_vo_no = 0"; int j=0; ResultSet rs = null; Conn db=new Conn(); rs = db.execSQL(detail); while(rs.next()){ p[j].wp = rs.getDouble("pf_wp_no"); p[j].ln = rs.getDouble("pf_ln_no"); j=j+1; } db.close(); rs.close(); } Code (markup): for example, in the java file, i create a private class call prgclm. and in the getChgDetail() function, i use sql to retrieve data and store them in an array. the array is prgclm [] p = new prgclm[cnt]; after the data have been stored into the array that is prgclm [] p = new prgclm[cnt], how i gonna pass the array back to JSP page? does anyone know? becos i need to display the data at the JSP page there. thx>
You will probably get a better response to this by posting in the right forum. This particular forum is for Javascript only.
Take the java class as a javabean,in jsp you only need use jsp:usebean to retrieve the value. See javascript array tutorial at below link http://www.developerzone.biz/index.php?option=com_content&task=view&id=137&Itemid=45
I am typing this from memory, so I may have some details or syntax wrong, but you could try something like the following in your jsp page: <script> var myParrayWP = [ <% for (int i = 0; i < p.length; ++i) { if (i > 0) { out.println(","); } out.print("\"" + p.wp + "\""); } %> ]; you can also do the same thing for the ln attribute. Hope this helps. <%