This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing session object from Tag Handler class.?

 
sean cee
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have written a custom jsp tag.
from JSP page I put some var into session object.
and from the same JSP page, I use the custom jsp tag.
but how can I use session object from tag handler class that is part of my custom jsp tag..
Thakns.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I recall, if your tag class extends the TagSupport class, you can do this:
HttpSession session = getPageContext().getSession() ;
The pageContext carries all of the default objects in a JSP for your convenience.
Bill

------------------
author of:
 
sean cee
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mr. Brogden !!!
 
Dustin Marx
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was happy to find this thread since this is exactly what I need to do -- access session information inside a custom tag. However, I had to change the code slightly from that mentioned above to get it to work. I was required to directly access the pageContext data member rather than being able to go through a getPageContext() acccessor method because no such method was available for me. So, my code looked like this:
HttpSession session = pageContext.getSession();
I am posting this in case someone else is able to benefit from this thread as I have.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic