Using JSP to operate cookies (2)

Source: Internet
Author: User

4. Notes

The preceding two simple examples show that it is very simple to use JSP to perform Cookie operations. However, we should pay attention to the following issues in actual operations:

1. Cookie compatibility

The Cookie format has two different versions. The first Version, called Cookie Version 0, was originally developed by Netscape and is supported by almost all browsers. The newer Version, Cookie Version 1, is developed according to RFC 2109. To ensure compatibility, JAVA stipulates that all the Cookie-related operations mentioned earlier are performed on old versions of cookies. The new Cookie version is not supported by the Javax. servlet. http. Cookie package.

2. Cookie content

The character restrictions of the same Cookie content vary with different Cookie versions. In Cookie Version 0, some special characters, such as space, square brackets, Parentheses, equal signs (=), commas, double quotation marks, slashes, question marks, @ symbols, colons, the semicolon cannot be used as the Cookie content. This is why we set the Cookie content to "Test_Content" in the example.

Although these characters can be used in Cookie Version 1, the new Cookie specification is not currently supported by all browsers. Therefore, it is safe, we should avoid using these characters in Cookie content. (

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.