Client technology: Cookie Service-side technology: HttpSession

Source: Internet
Author: User
Tags set cookie

Client technology: Cookie Service-side technology: HttpSession
    • 07. Five
    • /
    • Android Basics
    • /
    • No Comments

First, session technology
1, what is a session: The client opens a browser to visit a website, after the visit is finished, close the browser. This process is called a session. It's like making a phone call.
2, the main problem in the programming of the session is: to save the data information of each user.
3, the main technology to save the user's respective data:
Client Technology: Cookies
Service-Side technology: HttpSession


Second, cookies
1. Access to cookies using request.getcookies ()
2. Set cookie to use Response.addcookie (cookie C)
3. Properties of Cookies
3.1maxAge: The default is the browser's process. That is, if the property is not set, the cookie is deleted when the browser is closed.
You can also set the length of its survival, the unit is wonderful
3.2path: The default is the access path of the app that generated the cookie.
If a path is set, only resources that contain this path are accessible
If the set path is "/day06", that is, the cookie can only be accessed by day06 this app
If the path is set to "/day07" (the cookie added by Day06 's app), the cookie can only be accessed day07, and day06 is not accessible
If the set path is "/", the cookie can be accessed by all applications of the same server

Third, Session
1, IE7 and the following versions, the new open window will open a session
2. Each client has its own session object, which is identified by SessionID.
3, session technology is actually realized by using cookie technology. When the session is created, the ID of the session is written to the client in Cookie:jsessionid=sessionid form.
4. When does the session expire by default?
The time is up, and the default is 30 minutes.
Change the expiration time of the session
Modify the Web. xml file to add in the root element
<session-config>
<session-timeout>1</session-timeout><!– units for minutes –>
</session-config>
5. What if the client has disabled cookies?
Workaround: URL rewrite. The following two methods can implement overrides. The URL to which the station is to be overridden.
Response.encoderedirecturl (Java.lang.string?url): overriding for redirected addresses
Response.encodeurl (Java.lang.string?url): Other addresses to rewrite
(in the old browser, use localhost to access the site, even if the Cookie,cookie is disabled or valid)

Client technology: Cookie Service-side technology: HttpSession

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.