• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display data from an arraylist of more than one bean on jsp page using scripting or jsp tags?

 
James Haville
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm creating a project management website and have come across a problem. I can obtain the desired result using a scriptlet in a jsp but I would like to write the code in the servlet(controller). I have an arraylist of projectbeans of which I want to display all the information of when a client clicks on the projects button - i.e. - they will get the project id, date, and name of all the projects they are involved in.

Heres my code for the scriptlet in projects.jsp that works:



However I would like to write it in my projectsServlet and have some el scripting or jsp tags to display the information in my jsps

i.e. ${projectDetails} or jsp:useBean "projectDetails" etc etc

I can do it for one bean in the arraylist but I can not work out how to do it when there is more than one...

here is my lame attempt



and then I was thinking about displaying the project details based on the size of the arraylist but I still come back to my original problem...

In summary how do I display data from more than one bean in an arraylist of beans on my jsp page using scripting or jsp tags? I fear this is very simple but it has stumped me.

Thanks James
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL's <c:forEach>
 
James Haville
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep all done. Thanks for your help...

My new code:
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you got it working :)
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like your bean has a Date object. You can use the <fmt:formatDate> JSTL tag to format Dates.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!