Request details request.getSession ()?

I understand that if we use the following instruction

HttpSession session = request.getSession(); 

Creates a unique session identifier, creates a cookie, and associates a cookie with a session identifier.

and helps the container track and identify customers.

Yes, my question is, is it possible to see the header of the cookie and the unique identifier created using this request.getSession()? operator request.getSession()?

+4
source share
4 answers

You can get the HTTP Header using the HttpServletRequest.getHeader .

Although a session can be created by calling HttpServletRequest.getSession(true) it is more likely done by a webcontainer. As edl already wrote, HttpServletRequest.getSession().getId() returns the session identifier.

+3
source

You can see it using any HTTP header tracking 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 in the Set-Cookie header in the response. The client will send the same value as the Cookie header in subsequent requests in the same session so that the server can identify the client's session. For the JSP / Servlet web application, your interest is a cookie called JSESSIONID .

+3
source

You can use session.getId () for the id I consider. Not sure about the title.

0
source

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

0
source

Source: https://habr.com/ru/post/1311843/


All Articles