This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to set arraylist in formbean and display the same values in jsp

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have an action class, in which i read values from DB. i want to display those values in jsp using <html:select> as a listbox.

for this:
1)i declared one arraylist called statuslist in my formbean
2)im setting those retrieved values in action class to this arraylist like this.
while(rs.next())
{
fmActionForm = new FileManagementActionForm();
status = rs.getString("status");
statusList.add(status);
fmActionForm.setStatuslist(statusList);
}
3)in jsp, i try to display using <html:select> like this
<html:select property="selectedstatus" styleClass="select">
<html:options collection="statuslist" labelProperty="status" property="status"/>
</html:select>

i didnt use any session object to set and get in jsp for the arraylist.

Im getting error as: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean under name statuslist

can anybody tell me am i doing correctly or not?

thanks in advance,
kishore
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

a kishore wrote:

while(rs.next())
{
fmActionForm = new FileManagementActionForm();
status = rs.getString("status");
statusList.add(status);
fmActionForm.setStatuslist(statusList);
}
<html:select property="selectedstatus" styleClass="select">
<html:options collection="statuslist" labelProperty="status" property="status"/>
</html:select>








try above..
if not run then let me know the form and action in more details..
 
a kishore
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Ranveer,

i observed that you commented the line



in while loop. If i do so, the arraylist is storing only the last value when displaying in jsp.

my another doubt is, do i need to use session object to set arraylist in action class ? bcuz i use the following code to set arraylist in session. if i didnt put that in session, i couldnt get arraylist in jsp. it is throwing null pointer exception. any solution without session objects?

here is my code to set arraylist in session, in my action class



and my struts-config.xml action mapping is this:
 
No more fooling around. Read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic