gmhk
gmhk

Reputation: 15940

details of request.getSession() statement?

I understand that if we use the following statement

HttpSession session = request.getSession();

Will create the Unique session id, Create Cookie and associate Cookie with the Session id.

and helps the container to keep track and identify the clients.

Yes, My question, is there a possibility for me to see the cookie header and Unique Id created by this statement request.getSession()?

Upvotes: 4

Views: 6405

Answers (4)

BalusC
BalusC

Reputation: 1108702

You can see it using any HTTP header tracker tool. Firebug for example shows the headers in the Net panel. Here's a screenshot (click here for full size):

alt text

Any newly created cookie will appear as Set-Cookie header in the response. The client will send the same value back as Cookie header in the subsequent requests in the same session so that the server can identify the client session. For a JSP/Servlet webapplication, your interest is the cookie with the name JSESSIONID.

Upvotes: 3

gmhk
gmhk

Reputation: 15940

I found more information in the following URL http://www.javacertifications.net/javacert/session.jsp

Upvotes: 0

stacker
stacker

Reputation: 68962

You can retrieve a HTTP Header using HttpServletRequest.getHeader.

Although a session can be created by calling HttpServletRequest.getSession(true) it's rather done by the webcontainer. As edl already wrote HttpServletRequest.getSession().getId() returns the session id.

Upvotes: 3

edl
edl

Reputation: 3214

You can use session.getId() for the ID I believe. Not sure about the header.

Upvotes: 0

Related Questions