Working With Cookies
Trail: Custom Networking

Lesson: Working With Cookies

Though you are probably already familiar with cookies, you might not know how to take advantage of them in your Java application. This lesson guides you through the concept of cookies and explains how to set a cookie handler so that your HTTP URL connections will use it.

Java SE provides one main class for this functionality, java.net.CookieHandler, and the following supporting classes and interfaces: java.net.CookieManager, java.net.CookiePolicy, java.net.CookieStore, and java.net.HttpCookie.

HTTP State Management With Cookies

This page describes cookies and explains how they are used to provide sessions.

CookieHandler Callback Mechanism

This page explains how a cookie handler is called when you access a web site and how to set a cookie handler.

Default CookieManager

Java SE provides a default cookie handler implementation that is sufficient in most cases and highly customizable.

Custom CookieManager

Here are some examples of how to customize the cookie policy and write your own cookie store.


Problems with the examples? Try Compiling and Running the Examples: FAQs.
Complaints? Compliments? Suggestions? Give us your feedback.

Previous page: Previous Lesson
Next page: HTTP State Management With Cookies