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
"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.
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
Adam Chace<BR>Author of :<A HREF="http://www.amazon.com/exec/obidos/ASIN/193011009X/electricporkchop/102-2552103-3190518" TARGET=_blank rel="nofollow">JSP Tag Libraries</A><BR><A HREF="http://www.chalkcreek.com" TARGET=_blank rel="nofollow">Chalk Creek Software</A>
Joined: May 26, 2001
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).]