Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do u use session in taglib

 
Vadivel S
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
How do i store my data in session from the java class in which i've implemented my tag logic.
For ex. My class Sample extends TagSupport
Will i be able to access session object from this class?
Thanks & Regards
Vadivel
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Vadivel S",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
Adam Chace
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From within a tag handler, you can access the session most easily through the methods of PageContext class. An instance of the PageContext class is available to you, if your handler extends TagSupport or BodyTagSupport, automatically as "pageContext". You can get the session directly by calling:
pageContext.getSession()
or you can get and set values to the session through the cleaner:
pageContext.getAttribute( "attributeName", PageContext.SESSION_SCOPE )
pageContext.setAttribute( "attributeName", value, PageContext.SESSION_SCOPE )
Hope this helps,
-Adam
------------------
Adam Chace
Author of :JSP Tag Library
 
Vadivel S
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It's working fine and i was struggling with this problem for a week.
Actually I'm developing some custom tags to Connect, query and update the database.
I would like to have the resultset in some formatted data and cache it across the user session to avoid frequent database I/O.
Right now I'm storing the formatted data in session. By saying formatted data I mean, I have a class in which I store the data with some meta data.
If u have any suggestions please let me know.
Thanks & Regards
Vadivel S
[This message has been edited by Vadivel S (edited June 27, 2001).]
 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is pageContext's equivalent in servlet, the servlet application's ServletContext, or a new thing with the page scope?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic