Win a copy of Svelte and Sapper in Action this week in the JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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:
 
    Bookmark Topic Watch Topic
  • New Topic