• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display arraylist value in jsp, using JSTL tags?  RSS feed

 
Pradeep Prabhakaran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an arraylist object(e,g myArrayList),which contains a bean object.
Now if i m setting this object in request using:

request.setAttribute("myArraylist",myArrayList);

i want this object in my jsp. I know how to iterate the values using scriptlets, but i want to use jstl tags to retrieve the value of the Arraylist from the request object. N use the tags to display the values in jsp.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.crazysquirrel.com/computing/java/jsp/jstl-forEach.jspx

Or most anything else turned up by searching for c:forEach tag.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use forEach core jstl tag.


It's like Java foreach:
 
Pradeep Prabhakaran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Here, shouldn't i specify the type of the "var" in <c:forEach> tag.Will just the name of the bean object be sufficient.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the JavaRanch naming policy and change your display name to conform with this policy. Thanks!

You do not need to set the type. (I'm not even sure you can.) Wouldn't it just be easier to try it rather than wait for an answer?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Logan Wolverine wrote:
Here, shouldn't i specify the type of the "var" in <c:forEach> tag.Will just the name of the bean object be sufficient.

I couldn't understand you wordings. Check this documentation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!