This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Servlets and the fly likes getting session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting session" Watch "getting session" New topic

getting session

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
please assume this situation
for the first response to the client container sent both
Set-cookie and url rewritting..when it recives the second
raquest (the client browser supports Set-Cookie header
and sent both sessionID cookie and sessionID appended to URL)

from which part the above code reads sessionID

"I Love Java Ranch"
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3358

The mechanism of request.getSession() has the capability of tracking the session ID from URL or cookie. The session cookie, if presence, contains the session ID.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

You do not have to worry when the ID is readed.

Just know that the method "request.getSession();" brings you the client session.

And by default if is no session was created before (like first time in the page, timeout), it will creat a new session for you.

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
wood burning stoves
subject: getting session