• 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

Cannot find bean under name ....

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i have created my dropdown list, i am able to display data from the database, my jsp code look like this
<html:select property="resume" size="3" multiple="true">
<html ptions collection="usersCV" property="cvid" labelProperty="cvname" />
</html:select>
usersCV is the arralist which contains my bean, in turn bean contains cvid and cvname, my bean code look like this
public class UserCVList {
protected String cvname;
protected Integer cvid;
public void setCvname(String cvname) {
this.cvname = cvname;
}
public String getCvname() {
return cvname;
}
public void setCvid(Integer cvid) {
this.cvid = cvid;
}
public Integer getCvid() {
return cvid;
}
}
i could display the info properly once i submit the page, it is giving this error,
org.apache.jasper.JasperException: Cannot find bean under name usersCV
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
.................
and my action code look like this
public class UserCVListAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Default target to success
String target = new String("success");
ArrayList usersCV = null;
try{
usersCV = UserData.getUserCVs(getDataSource(request));
if(usersCV == null) {
target = new String("login");
}else{
request.setAttribute("usersCV", usersCV);
}
} catch ( Exception e ) {
System.err.println("Setting target to error");
target = new String("error");
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("errors.database.error", e.getMessage()));
// Report any errors
if ( !errors.isEmpty() ) {
saveErrors(request, errors);
}
}
// Forward to the appropriate View
return (mapping.findForward(target));
}
}
my database method look like this
public static ArrayList getUserCVs(DataSource dataSource) {
UserCVList cvlist = null;
ArrayList userCVs = new ArrayList();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from cvtable");
while (rs.next()) {
cvlist = new UserCVList();
cvlist.setCvname(rs.getString("cvname"));
cvlist.setCvid(new Integer(rs.getInt("cvid")));
userCVs.add(cvlist);
}
.......
return userCVs;
}
could u plz help me out
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using the options tag, define the collection bean before using it. You create a JSP bean that you can call by it's id attribute. So in this case you would do the following:

I think that will work for you.
HTH,
E
 
P. Udaya Shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
even i tried by defining, for that i am getting error like this...
org.apache.jasper.JasperException: Cannot find bean usersCV in scope request
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
.......
could u plz help me out
 
P. Udaya Shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
if say <%= request.getAttribute("usersCV") %> in my jsp it is displaying the
values.
i used define in my jsp it looks like this
<bean efine id="usersCV" name="usersCV" scope="request" type="java.util.ArrayList"/>
<html:select property="resume" size="3" multiple="true">
<html ptions collection="usersCV" property="cvid" labelProperty="cvname" property="cvname" />
</html:select>
still it is saying this error
org.apache.jasper.JasperException: Cannot find bean usersCV in scope request
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
...........
could u get me the soln for this
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I always use this :
session.setAttribute( "editors", editors );
<html:form action="/Save" name="myForm" type="com.ctg.dspv.services.admLegalPerson.CreateUpdateForm" scope="session">
<html:select name="myForm" property="editorName">
<html ptions collection="editors" property="id" labelProperty="name"/>
</html:select>
</html:form>
The only difference with your solution is that I put it in the session =>
try to put it in the session and see if it is working.
I never use a define in this Case.
Hope this works.
Nathalie
 
P. Udaya Shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Thanks a lot it is working,
i have set to session & even i am not defining the bean
it is working, may i know the reason for the problem, why it is not working with request. plz give me the technical reason
 
Nathalie Keymeulen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I am sorry, but I cannot give you an explanation about this.
When I red your post I remembered that I had the same problem a few months ago. I remembered that changing it to session was the solution.
I think this is a bug. I searched the web and I didnt found an explanation.
Normally <html ptions> works with request and session.
It also has to work with request I found this on the web :
http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/29/pid/946/qid/703650
Regards
Nathalie
[ December 02, 2003: Message edited by: Nathalie Keymeulen ]
 
Eric Fletcher
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting, I've never come across that issue because I don't think I've ever used the options tag with a request scope variable, AFAIK I've always used session scope for my collections. In any event, I was under the impression you had to define the bean, so I've always defined it before using. Just goes to show you learn something new every day!
Sorry about the bad advice P. Udaya.
Cheers,
E
reply
    Bookmark Topic Watch Topic
  • New Topic