Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retreiving value from bean

 
hasan wasif2k1
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m having problem when retreiving value from bean using array. How can i solve it.
JSP file
File name:- test.jsp
<jsp:useBean id="t" class="bean.test" scope="request" />
<% String[] count=t.send();
%>
Bean File
File name:- test.java
package bean;
public class test{
private String s[];
public String[] send(){
s[0]="Hello";
s[1]="Hi";
return s;
}
}
Error it gives is "Exception: java.lang.Exception: bean.test: method send()[Ljava/lang/String; not found"
 
Roopa Bagur
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where is your compiled class file for your bean located
Originally posted by hasan wasif2k1:
I m having problem when retreiving value from bean using array. How can i solve it.
JSP file
File name:- test.jsp
<jsp:useBean id="t" class="bean.test" scope="request" />
<% String[] count=t.send();
%>
Bean File
File name:- test.java
package bean;
public class test{
private String s[];
public String[] send(){
s[0]="Hello";
s[1]="Hi";
return s;
}
}
Error it gives is "Exception: java.lang.Exception: bean.test: method send()[Ljava/lang/String; not found"

 
hasan wasif2k1
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no problem with location of class file as the same program works when only a single value is returned instead of array. Written below is the program which works.
JSP file
File name:- test.jsp
<jsp:useBean id="t" class="bean.test" scope="request" />
<% String count=t.send();
out.println(count);
%>
Bean File
File name:- test.java
package bean;
public class test{
private String s;
public String send(){
s="Hello";
return s;
}
}
prints Hello
 
Syam Veerakumar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since its a String array u have to instantiate it like
String s[] = new String[2];
[This message has been edited by Syam Veerakumar (edited October 12, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!