What Is a Cookie?

This section describes what is a cookie - a small amount of information sent by a Web server to a Web browser, saved by the browser, and sent back to the server later.

What Is a Cookie?: A cookie is a small amount of information sent by a Web server to a Web browser, saved by the browser, and sent back to the server later. Cookies are transmitted inside the HTTP header.

Cookies move from server to browser, and back to server as follows:

Web         Web         Local       Web           Web
Server      Browser     System      Browser       Server

Send        Receive     Save        Send back     Receive
cookies --> cookies --> cookies --> cookies   --> cookies

As you can see from the diagram, cookies are actually saved to the memory or hard disk of Web browser user's machines. Many users are concerned about this. But I think it is pretty safe to allow your browser to use cookies.

If you are really concerned, you can change your browser's settings to reject cookies. But this may cause many Web based applications fail to run on your browser.

If you are using IE (Internet Explorer) on Windows 7, some cookies are stored in the Microsoft folder in your profile. You can look at them using a command window. But they are stored in multiple files in random names:

C:\>dir \Users\herong\AppData\Roaming\Microsoft\Windows\Cookies>
   378 MH1M64UB.txt
   102 N31PUJ47.txt
   210 E2N0HL2B.txt
    74 VTX5T7K7.txt
   100 D800RRJK.txt
   199 YZI4VETO.txt
...

If you are using Firefox on Windows 7, some cookies are stored in the Mozilla folder in your profile. You can look at them using a command window. But they are stored in a SQLite data file:

C:\>dir \Users\herong\AppData\Roaming\Mozilla\Firefox\Profiles
   \o1ri26bj.default\cookies.*

   524,288 cookies.sqlite
    32,768 cookies.sqlite-shm
         0 cookies.sqlite-wal

Last update: 2012.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

Managing Cookies in JSP Pages

What Is a Cookie?

 Sending and Receiving Cookies in JSP Pages

 Persistent Cookies Stored on Hard Disk

 Persistent Cookie Test Example

 Dumping HTTP Response with Cookies

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials

 References

 PDF Printing Version