This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSP and the fly likes sharing session objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "sharing session objects" Watch "sharing session objects" New topic

sharing session objects

cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
I would like to know where it is stipuled that
In order to share the same shopping cart object between requests, the same session object that is associated with a user would be required. However, when requests are made by the same user to different web applications, the same session object cannot be retrieved using the getSession() and getSession(boolean create) methods declared by the interface javax.servlet.http.HttpServletRequest.

extracted from a mock exam.
So, the session may only be retrieved from the same web application?
I would be very grateful for any precision about this topic,

SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32815

This is from the J2EE spec (available on the site.) It states that web applications cannot share sessions. However, servlets within a web application can share a session.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Read the Servlet 2.2 specification, page 36, section 7.3 on "Session Scope", or the Servlet 2.3 specification, page 51, section SVR7.3, or the Servlet 2.4 specification, page 56, section SVR7.3.
They all say the same thing.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
Thanks Kyle for this very precise answer.
I agree. Here's the link:
subject: sharing session objects
It's not a secret anymore!