The cookie protocol, piggy-backed on HTTP is described in RFC 2965.
| How Cookies Work | Puzzles |
| Confidentiality | Books |
| Obsolete | Learning More |
| Modern | Links |
The HTTP format of cookies in the HTTP header the server sends to the client is somewhat more human-readable. e.g.
Cookies can be used to track logins. The client sends in a an authentication cookie with each request to remind the server it is logged in and offers some proof it is, and a hint to who it is so the server can pick up the conversation where it left off.
Applets too can play with cookies, but only with the ones put there by the server from which they were loaded, or that were put there by Applets from that server. Applets can both read and write the cookies stored in the browser, just as the server can.
For early Java, you will also have to put the file \Program Files\netscape\communicator\program\java\classes\java40.jar on the classpath when you are compiling. In Java 1.4 JSObject comes bundled in jaws.jar. In Java 1.5+ it comes bundled in plugins.jar. Last revised: 2007-04-25 The IE browser will deal with finding the classes at run time. Unfortunately, the only browser I found that supports the official method [see code snippet below] is Internet Explorer 5.5/6.0.26. Not even Netscape 4.79 works!
I have only been able to get cookies to work the official way in IE 5.5, not Netscape or Opera. Best to always use the field-at-a-time method [see code snippet above]. It works in IE, Firefox, Opera, Safari and Netscape and likely the most of the others. You could also try with JavaScript read/write cookie functions.To handle cookies in a client Applet you use java.net. CookieHandler. You use the static method CookieHandler. getDefault to get you the CookieHandler registered to store and retrieve all cookies for the browser. You don’t have to write your own CookieHandler. Then you use the get method of the CookieHandler object to get a list of all the relevant fields. You write a system-wide cookie handler and register it with the HTTP transport mechanism.
I am not clear on how this is supposed to work. Please pass on any relevant lore. Here is my best shot so far:
![]() |
recommend book⇒Core Web Programming, Second Edition | |
| paperback | ||
|---|---|---|
| ISBN13: | 978-0-13-089793-0 | |
| ISBN10: | 0-13-089793-0 | |
| publisher: | Prentice Hall | |
| published: | 2001-06-03 | |
| by: | Marty Hall and Gary Cornell | |
| 1250 pages. This is a great doorstop of a book. It has a few chapters on client-server programming in Java, and a section of that is on CGI. I have looked at hundreds of Java books and found nothing that deals in depth with client side Java talking to CGI, except Marty’s book. It is really very simple and he does an excellent job of explaining it. Marty has posted all the source code examples from the book for anyone to use. These contain updates and errata fixes you don’t get on the CD-ROM that comes with the book. | ||
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.62] | The information on this page is for non-military use only. | ||
| You are visitor number 25,196. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | ||
| http://mindprod.com/jgloss/cookie.html | J:\mindprod\jgloss\cookie.html | ||