Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Iterating through a list from the session

 
Ranch Hand
Posts: 240
3
  • 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.

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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: 240
3
  • 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 VI Editor Redhat
  • 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 VI Editor Redhat
  • 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 c:out actions.
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • 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: 240
3
  • 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.
    Bookmark Topic Watch Topic
  • New Topic