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. (