• 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 do u use session in taglib

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic