JEE - Servlets


Servlet Processing

http://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-session-variables-and-multithreading


Session management - HttpSession HttpServletRequest.getSession()
Session maintained by
1. Cookies (request parameter JSESSIONID contains the cookie value).When using cookies, the server asks the client to store a cookie by setting the Set-Cookie HTTP response header

Set-Cookie: JSESSIONID=ABAD1D;path=/
Cookie: JSESSIONID=ABAD1D

2. URL Rewriting - When using URL rewriting, this same session ID is instead sent somewhere in the URL. Again, the server extracts the session ID from the URL so that it can lookup the session for a particular client:

http://my.app.com/index.jsp;JSESSIONID=ABAD1D

The server must also make sure that any URLs in the web pages sent back to the client are also rewritten to contain that particular clients session ID. As the session ID is encoded in the URLs, this method of session tracking is transparent to the browser. Often a server will resort to URL rewriting if it finds it is unable to set a session cookie on the client - implying that the client does not support/allow cookies.

No comments:

Post a Comment