• 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Scriptlet vs JSTL  RSS feed

 
Author
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set this up on Tomcat 5.0.28 with JSTL 1.0. I have a servlet that puts a List into session then calls a JSP


The JSP pulls it out and iterates through it.
If I run this JSTL JSP it works good:


But if I use JSP with a scriptlet this doesn't find the List


You make ask why am I doing this. I am trying to debug something else. Am I doing something wrong with scope?
Thanks in advance,
Tom

[ December 14, 2005: Message edited by: Tom Henricksen ]
[ December 14, 2005: Message edited by: Tom Henricksen ]
 
Marshal
Posts: 67225
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Tomcat 5 you should be using JSTL 1.1.
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your scriptlet, you are trying to get the list from the request. But, in your servlet, you added the list to the session.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>Am I doing something wrong with scope?
you put the attribute into session scope:
request.getSession().setAttribute("list",list);

and then try to retrieve it from request scope:
List list = (List)request.getAttribute("list");

Do you think that should be reason enough?

The reason JSTL works is that it uses the method pageContext.findAttribute("list") to search through page, request, session then application scopes (in that order) to find the appropriate attribute.

That is also why you were able to use ${list} as the name of both your "list" AND the temp variable you were using to iterate over the list.
Their fully qualified names would be ${pageScope.list} and ${sessionScope.list}. The first time you use ${list} it matched the list in session scope. After that it used the variable in the page scope.

Normally I would recommend that you you use different names for var and items - just to save confusion.
 
Tom Henricksen
Author
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all very much! I appreciate your help with this.

Tom
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!