Results 1 to 5 of 5

Thread: Return array from java file to JSP

  1. #1
    Join Date
    May 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Return array from java file to JSP

    Code:
    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();
    }
    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>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i already go and look through the useBean directive, but still do not know how to pass back the
    private class prgclm
    {
    double wp;
    double ln;
    int cnt;
    }

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You don't. It's private. That's kind of the point.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    make it public?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •