开发者

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 cre开发者_StackOverflow社区ated by this statement request.getSession()?


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.


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):

details of request.getSession() statement?

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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜