• 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

How can i get session value in my JSP page using JSTL

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

i am new to java and i have assigned a task that i need to get value from Session value using JSTL. I know how to get session values using java script let. But i don't know how to get session value using JSTL.

I gone through some examples and followed as it is. But its not getting value using JSTL.

What i done.

In our application we have created sessionManager class, in that class we have used setter/getter methods. Through this method we will get / set the values into sessionManager object. This sessionManager object has been added into session object.

Using session.setAttribute("SMGR", sessionObject);

i am getting output

navigation.jsp ** myPage jsp size - 3
page Name ********: menuManager
page Name ********: userManager
page Name ********: userTypeManager



i am getting values in my JSP page using scriptlet .

while using JSTL i didn't get the value. Where i done the mistake. This is my JSTL code.
 
Greenhorn
Posts: 21
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are setting the object into session using "SMGR" as the attribute name. When using JSTL to get it from session you need to be using that same name:
sessionScope.SMGR....
 
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
You use the EL, not the JSTL: ${SMGR}

(But really, "SMGR"? I'd pick a more readable variable name.)
 
saravanan sambandam
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

Thanks for your response, but i did not get you.

Please tell me. What i need to do there?

You use the EL, not the JSTL: ${SMGR}

(But really, "SMGR"? I'd pick a more readable variable name.) -- "SMGR" is a attribute name to get the object from session. after that i want to get pageList as an arrayList type Object. So far i used property myAccessPage, which has both getter & setter method.


It looks like you are setting the object into session using "SMGR" as the attribute name. When using JSTL to get it from session you need to be using that same name:
sessionScope.SMGR....

even i tried with your guideline. I didn't get the result. I made the mistake some where and i uable to identify.




Could you point me where i did the mistake.

Thanks
Saravanan.s.
 
Markas Korotkovas
Greenhorn
Posts: 21
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting that in your scriplet you are using the "sessionManagerVariable" to get the sessionManager object from session. But in the JSTL tags you are not using the same name. Are there several different session manager objects in the session or am i missing something?
 
saravanan sambandam
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! thanks you pointing out me mistakes.

I tried after i changed my code. Till i am getting the no result. Please give me some sample code. It would help me more..

 
Markas Korotkovas
Greenhorn
Posts: 21
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As with any other technology you should start with the most basic thing in order to make more complex things later. In your code example you are trying to create a menu using an iterator with an if statement inside as well without having figured out the basics. Start small. Try to get a string attribute from the manager (if available) and output it to the page. Once you can get that working get the simple iterator with static text inside working. Once that is done start adding other elements and etc. I know it is tedious, but that is the way to learn. If i provided you with a solution right away you would not learn and i would be doing all the work for you.
 
saravanan sambandam
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Thanks for your supports.

I got the result by this ${sessionScope.SessionVariable.accessPage}

sessionScope <--> session
SessionVariable <--> attribute name
accessPage <--> one of the property
 
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
Joe Martin,
Your post was moved to a new topic.
reply
    Bookmark Topic Watch Topic
  • New Topic