File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Session identification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session identification" Watch "Session identification" New topic
Author

Session identification

Sumit Bansal
Greenhorn

Joined: Feb 27, 2007
Posts: 19
Hi,

HttpServletRequest interface has a method named getSession()
which says it returns the current session associated with this request, or if the request does not have a session, creates one.

My question is how is it identified by server, I mean the session belong to the current request?

Where does it search for the session which belongs to current request?

thank you


Sumit Bansal<br /> <br />SCJP 5.0
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi Sumit,

Session tracking for servlet containers works similar to session tracking in "ordinary" HTTP servers. Servlet containers may use cookies to identify clients by the generated session ID stored in the cookie. As a fallback solution it's also possible to use URL rewriting to encode the session ID into the URL. For SSL connections the container may additionally use the session mechanism integrated in the SSL protocols.

Marco
Sumit Bansal
Greenhorn

Joined: Feb 27, 2007
Posts: 19
Hi Marco,

Thanks for reply.

one more query.. If a user login to an application using two different browser from same machine, would the same session Id be generated by container or there will be two different session id?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Sumit Bansal:
If a user login to an application using two different browser from same machine, would the same session Id be generated by container or there will be two different session id?


1.two different browser-----------> then two different session id

2.two different window from same browser-----------> then only one session id

Hope this helps
Juva Yuva
Greenhorn

Joined: Dec 18, 2008
Posts: 17
Originally posted by seetharaman venkatasamy:


1.two different browser-----------> then two different session id

2.two different window from same browser-----------> then only one session id

Hope this helps


And thats why session attributes are not thread-safe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session identification
 
Similar Threads
Confused about getSession
isRequestedSessionIdValid == false every time
Session related Question
QUESTION ABOUT SESSION
When is a HttpSession object created by the Web Container