I am trying with sample application to display values from object set in Action and trying to populate the same object values in jsp. But it is not populating in JSP file
Please help me, how to populate object values in jsp....
There are two problems with your code. One of them is logical and very small, since you know that you'll get only one row from your SQL statement, so you should use if condition instead of while loop i.e. if(result.next()) instead of while(result.next()). Now the id/var attribute of the s:bean tag is used to give the name of a bean on the value stack, but userList is a local variable not a field in your action class. If you move the declaration of userList outside of the execute method, your code should work...
Thanks for your quick response. I moved creation of userList object outside the execute method, but still nothing is displayed in the customerList.jsp.
Is there any other way, other than s:bean usage to access object in jsp like need to configure form-bean in struts.xml[I dont think it is required in struts 2.0]
I am not able to understand how to access object members from jsp page. Please let me know the solution.
Is there any other way, other than s:bean usage to access object in jsp
Yes, you can do it without using the s:bean tag like this
I actually didn't know the purpose of s:bean tag before this, it actually instantiates a new object and pushes it into the value stack, so your code won't work when you use s:bean tag even if you moved userList out of the execute method (as you already did)...
Joined: Jan 19, 2004
I tried with these below code options, but still not getting userList object members.