Purple Code

com.purpletech.servlets
Class CookieDetector

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.purpletech.servlets.CookieDetector
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class CookieDetector
extends javax.servlet.http.HttpServlet

This servlet detects whether the client accepts cookies. It acts as a gateway, eventually sending the user to one of two URLs. One URL results when the user has accepted the cookie; another results either if the user rejected the cookie, or if the user's browser does not support cookies. The intention is to use the "no-cookie" page as a message to the user saying "this site requires cookies -- pretty please accept my cookies or the site won't work right."

The sequence of events is:

Use the urlCookies and urlNoCookies init parameters to specify the destination pages for clients that accept and rejct cookies, respectively.

(It would be nice if all implementations of Session Tracking used a similar technique. As it is, some servlet engines seem to just check whether the browser can potentially support cookies, not whether a particular user has disabled cookies for this session or site.)

Download the source

See Also:
Serialized Form

Constructor Summary
CookieDetector()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieDetector

public CookieDetector()
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws java.io.IOException,
                  javax.servlet.ServletException
Overrides:
doGet in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException

Documentation generated March 5 2003