1. The Java Servlet API references the Session mechanism to track the status of the customer. The Javax.servlet.http.HttpSession interface is defined in the servlet API, and the servlet container must implement this interface. 2. When a session begins, the servlet container creates a HttpSession object, and the servlet container assigns a unique identifier, called the Session ID, to HttpSession. The Servlet container stores the Session ID as a Cookie in the client's browser. Each time a customer makes an HTTP request, the Servlet container can read the session ID from the HttpRequest object and then find the corresponding HttpSession object based on the session ID to obtain the customer's status information. 3. When the client browser prohibits the Cookie,servlet container from getting the Session ID as a Cookie from the client browser, the customer status cannot be tracked. Another mechanism for tracking the session is presented in the Java Servlet API, where the client browser does not support the Cookie,servlet container to rewrite the URL of the client request and add the session ID to the URL information. 4. HttpServletResponse interface provides a way to rewrite URLs: public java.lang.String encodeurl (java.lang.String URL)
The implementation mechanism of this method is:
First, determine whether the current Web component is session-enabled, and if not, return the parameter URL directly.
Again determine whether the client browser supports cookies, if a cookie is supported, directly returns the parameter URL, if the cookie is not supported, the Session ID information is added to the parameter URL, and then the modified URL is returned.
We can modify the links in the webpage to solve the above problems:
Before modification:
<a href= "maillogin.jsp" >
After modification:
<a href= "<%=response.encodeurl (" maillogin.jsp ")%>" >
Path URL problem