• 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

accessing context parameters with out using declaration tag

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
i have created a struts application, in which i have created 4 jsp pages. In 2nd and 3rd pages i m taking some data from the user and setting that data as context parameters using the HttpSession object. now i want to access these context parameters in the 4th jsp page but with out making use of the declaration tag(<%= java code %>). i wanted to know how can this be performed...??? any help is appreciated.....

thanks.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can get it in two ways using EL

suppose you have an object named "testObj" in session scope which you have created using setAttribute

for getting it in jsp

1. ${testObj.name} -------- assuming that testObj has a property called name
2. ${sessionScope.testObj.name}


Finally include the below taglib directive
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neil johnson wrote:Finally include the below taglib directive
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


The JSTL is not necessary in order to use the EL.

But, of course, you should be including it so that you can use the JSTL!
 
Naveen Megharaj
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i m new EL, till now i used to make use of scriptlet, declaration and expression tag in my jsp's.
my doubt is in order to make use of EL variable in my 4th jsp page, do i need to define then previously in my 2nd and 3rd jsp pages, where i m accepting the data from the user and setting that data as context parameters. actually i m setting user data as context parameters in my action classes.
thanks
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"context parameter" is not the correct term; it's "scoped variable".

And it doesn't matter what has set up the scoped variable, the EL can access andy scoped variable.
 
neil johnson
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Naveen Megharaj wrote: But i m new EL, till now i used to make use of scriptlet, declaration and expression tag in my jsp's.
my doubt is in order to make use of EL variable in my 4th jsp page, do i need to define then previously in my 2nd and 3rd jsp pages, where i m accepting the data from the user and setting that data as context parameters. actually i m setting user data as context parameters in my action classes.
thanks




not required. If you save it in HttpSession it is available throught out the session. so you can directly access it in the fourth jsp.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that's exactly what he is talking about, just using the term "context parameter" incorrectly.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic