Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
a kishore
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">
<htmlptions 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
 
Ranveer K Kumar
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">
<htmlptions 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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic