Exploring the management of cookie libraries in j2s

Source: Internet
Author: User
Tags send cookies

If you are familiar with the cookie management solution in j2's, I would like to share it with you here. The cookie library is rare in the inherent java.net toolbox. In this article, the Cookie Management Library tries its best to use the core JavaAPI class.

Cookie management solution (1)-combined

Preface

Client HTTP status management is very important for creating java applications that need to interact with e-mails Based on Web browsers or online banking network programs. This article describes a powerful and easy-to-use client HTTP status management cookie library in Java, which is rare in the inherent java.net toolbox. There are several clients that manage the HTTP status of APIs. They provide function methods that are difficult to learn and do not need to be re-developed. In this article, the Cookie Management Library tries its best to use the core Java API class.

When developing a universal mail client that provides single-point access for all major internet mail servers based on Web or other types, I found that my applications often have to interact with mail service websites as a small Web browser. When developing xml network services to make it easier for machines to access websites, I always encounter difficulties in website interaction. These websites often use cookies for status management and user session data maintenance. In these two cases, I realized that most website interactions involve cookie operations. I have also noticed that although both applications perform cookie operations, the logic processing is difficult and not interchangeable. To address this restriction, I started to work on cookie operations by developing a small general-purpose library. In this article, I will share this library with you.

To illustrate the library during running, I suggest using the Hotmail email detector-based console. In addition, I explored client status management from the perspective of mobile devices using MIDP ON THE j2's platform.

Cookie Basics

Let's start with answering some questions:
What is status management? Why do we need it?
What are cookies? How do they adapt to images?

To answer the first question, we must more precisely detect HTTP. HTTP is borderless, because from the network server perspective, all HTTP requests are independent of previous requests. That is to say, each HTTP response is completely dependent on the information contained in the corresponding request. When such behavior makes the network service execution simpler and more effective, it is more appropriate to use it as the basis for complex network applications.

The status management mechanism overcomes HTTP restrictions and allows network clients and servers to maintain the relationship between requests. The period in which this relationship is maintained is called session ). Most network applications requiring you to log on use session and status management. The shopping cart application uses status management to control the list of all items marked as purchased. Status Management allows you to customize the entry and search engine of individual user parameters. Network applications can even use status management to customize website content based on user interests.
Cookies affect status management. Cookies are small pieces of text stored by the server on the local machine and are sent to the same server as each request.

Ietfrfc2965httpstatemanagementmechanic is a general cookie specification. The network server uses the HTTP header to send cookies to the client. On the client terminal, the browser parses these cookies and saves them as a local file, it will automatically upload these cookies to any request sent to the same server. Later in this article, I used cookie operations and status management terminologies synonymous.

If you want to find out which website you visit uses cookies, you can try this simple experiment:
Note: This exercise is executed only when you feel that it is okay to change your browser settings and know the method.

◆ Open your common browser. I suppose you are using InternetEXPlorer (IE) 5 + or NetscapeNavigator4 +.

◆ Invalid automatic cookie operation:

Select "Internet Options" from the "Tools" menu of IE browser, and then select the "Security" tab, click "Custom Level" and pull down until you see "Allow to use cookies stored on your computer" and select the "prompt" option, at the same time, select the "prompt" option "allow each dialog cookie (not stored)" and click "OK" to return to the main window.

In the "edit" menu of NetscapeNavigator, select "advanced" in "parameter selection", select "receive cookie warning", and click "OK" to return to the main window.

◆ Browse your favorite sites now, especially when you check your online emails or enter the online e-store, the dialog box asking you to allow cookies to be received will continue to hit you.

Restore the preceding steps to your previous initial settings. You can also see which cookies are saved to your local machine before warning the application ):

◆ For IE: Use "Windows Resource Manager" or "My Computer" to browse the C: Windows cookies folder. All text files in this folder contain cookies.

◆ For NetscapeNavigator:

In Windows, use "Windows Resource Manager" or "My Computer" to browse the C: programfilesnetscapeusers folder and find a file named "cookies.txt" or a "cookies" subdirectory.

In Unix-like systems, find a file named "cookies" in the ". netscape" directory.

Note: The steps for disabling automatic cookie operations and viewing stored cookies may vary depending on the system you have installed.

Now you know some basic knowledge. Next I will explain how to associate these with Java.
 

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.