• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retreiving value from bean

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Can't .... do .... plaid .... So I did this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic