• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL pageScope

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I dunno if this question has already been asked. If it has, will you pls direct me to that post?
The following code sets a variable 'str' and correctly outputs: "yoohoo"
<c:set var="str" scope="page" value = "yoohoo" />
<c ut value = "${pageScope.str}" default = "null" />
-----------------------------------------
But the following code outputs the default value "null"
I even removed the forced reference to the page scoped .. i.e. just ${str} and it still dint work
Could you pls tell me why? I thought that the scriplet sets a variable str in page scope just like the <c:set> tag
<%
String str = new String ("yoohoo");
%>
<c ut value = "${pageScope.str}" default = "null" />
Environment used: JBuilder6.0 on Tomcat 4
Thanks!
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page-scoped attributes are different from scripting variables. There is no way for a JSP tag to read local scripting variables. If you want to expose a scripting variable as an attribute you'll need to do so explicitly, as with
<% pageContext.setAttribute("str", str); %>
JSTL's design encourages you to avoid scripting variables in the first place and use scoped attributes instead, initially.
Hope that helps!
 
Goldie Fernandes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shawn,
Thanks for your reply!! Really helped.
Guess i should go for your book!
Have a nice day.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic