Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

JSP: storing Object to PageContext

Thread view: 
bruce_phipps@my-deja.com - 14 Dec 2006 14:04 GMT
JSPs seem to offer more than one way of storing Objects to a session
context for session tracking purposes.

Both these seem to work Ok in my JSP code on Tomcat 5.0.x:

// using pageContext with session scope
pageContext.setAttribute("name", myObject, PageContext.SESSION_SCOPE);

// using the session context of HttpServlet
session.setAttribute("name",myObject);

Whats the difference here? Is there a preferred way to do this?

Thanks
Bruce
Manish Pandit - 14 Dec 2006 19:12 GMT
> JSPs seem to offer more than one way of storing Objects to a session
> context for session tracking purposes.
[quoted text clipped - 11 lines]
> Thanks
> Bruce

Under the hood, they are same. PageContext is a wrapper allowing access
to all scopes (application, session and request), as well as the
implicit objects (request, response). Personally I prefer the
session.setAttribute(name,value) as it is more reader-friendly when
looking at the code.

-cheers,
Manish
bruce_phipps@my-deja.com - 15 Dec 2006 09:32 GMT
> Under the hood, they are same. PageContext is a wrapper allowing access
> to all scopes (application, session and request), as well as the
[quoted text clipped - 4 lines]
> -cheers,
> Manish

Thanks, Manish. As I suspected, they both do exactly the same....

Bruce


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.