aspose file tools*
The moose likes Servlets and the fly likes accessing session object from Tag Handler class.? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "accessing session object from Tag Handler class.?" Watch "accessing session object from Tag Handler class.?" New topic
Author

accessing session object from Tag Handler class.?

sean cee
Ranch Hand

Joined: Oct 24, 2000
Posts: 115
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.


Sean <br />SCJP2, SCJP2p1.4, SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Oct 24, 2000
Posts: 115
Thank you Mr. Brogden !!!
Dustin Marx
Ranch Hand

Joined: Mar 06, 2001
Posts: 40
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: accessing session object from Tag Handler class.?