Path URL problem

Source: Internet
Author: User
Tags session id

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.