Common HTTP 1.1 Response
Headers (Continued)
Location
The URL to which browser should reconnect.
Use sendRedirect instead of setting this directly.
Refresh
The number of seconds until browser should reload page.
Can also include URL to connect to. See following
example.
Set Cookie
The cookies that browser should remember. Don't set this
header directly; use addCookie instead.
WWW Authenticate
The authorization type and realm needed in Authorization
header. See details in More Servlets & JavaServer Pages.
63
Servlets
www.corewebprogramming.com
Persistent Servlet State and
Auto Reloading Pages
Idea: generate list of large (e.g., 150 digit)
prime numbers
Show partial results until completed
Let new clients make use of results from others
Demonstrates use of the Refresh header
Shows how easy it is for servlets to
maintain state between requests
Very difficult in traditional CGI
Also illustrates that servlets can handle
multiple simultaneous connections
Each request is in a separate thread
Synchronization required for shared data
64
Servlets
www.corewebprogramming.com
32