• Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterating through a list from the session  RSS feed

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the code below. The first line (toString) writes all the values that were placed in the array, line two (size) gives the correct size...but the loop writes out nothing. I am not sure what I am doing wrong here. Any tips would be greatly appreciated.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't mix scriptlets with JSTL/EL.
They weren't meant to work together.
(and it's ugly to do so)


Use an EL expression for the items attribute.

[ April 09, 2008: Message edited by: Ben Souther ]
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Ben, my issue is I am not sure how to get the session attribute with EL. Here is what I have now. Still not working like its intended too.


[ April 09, 2008: Message edited by: Luke Shannon ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EL searches through all the scope objects to find the attribute.

You're c:set tag doesn't look right.
Read up on the 'scope' attribute in the c:set action.

What version of JSTL are you using?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is all you should need:



And if you're using JSP 2.0 (JSTL 1.1) you shouldn't need the cut actions.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jar in the lib directory is jstl-1.1.2.jar.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has got it Ben, thanks very much.

Another issue was this was being included in another page when the application runs (this is how I was testing), I thought there was a <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> in the page doing the including, but I just found out there wasn't. Once I added that to my page everything was great.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!