Review: Generating the HTTP
Response (Continued)
Most important status codes
200 (default)
302 (forwarding; set via sendRedirect)
401 (password needed)
404 (not found; set via sendError)
Most important headers you set directly
Cache Control and Pragma
Content Encoding
Content Length
Expires
Refresh
WWW Authenticate
101
Servlets
www.corewebprogramming.com
Review: Handling Cookies
Cookies involve name/value pairs sent from
server to browser and returned when the
same page, site, or domain is visited later
Let you
Track sessions (use higher level API)
Permit users to avoid logging in at low security sites
Customize sites for different users
Focus content or advertising
Setting cookies
Cookie constructor, set age, response.addCookie
Reading cookies
Call request.getCookies, check for null, look through
array for matching name, use associated value
102
Servlets
www.corewebprogramming.com
51