ch7.accountCookie
Class Controller

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by ch7.accountCookie.Controller
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Controller
extends javax.servlet.http.HttpServlet

Similar to the Account Login application, except it stores the account number in a cookie. If the cookie is present, then the application bypasses the login bage and proceeds to the edit page, filling the form elements with the data from the database for that account number.

See Also:
Serialized Form

Constructor Summary
Controller()
           
 
Method Summary
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          When the browser makes a GET request, this is the method in the controller that is called.
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          When the browser makes a POST request, this is the method in the controller that is called.
 void init()
          This method is called once, when the servlet is loaded into memory.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller()
Method Detail

init

public void init()
This method is called once, when the servlet is loaded into memory. The controller helper class will have a static method that will be used to initialise Hibernate. It will be called from this method so that Hibernate is only initialised once per web application.

Overrides:
init in class javax.servlet.GenericServlet

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws java.io.IOException,
                     javax.servlet.ServletException
When the browser makes a GET request, this is the method in the controller that is called.

The work of the controller will be handled by the helper. The controller will create the helper class and call its doGet method to process the request.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - Encapsulates all of the request information that is needed to communicate with the browser.
response - Encapsulates all of the response information that is needed to communicate with the browser.
Throws:
javax.servlet.ServletException - A servlet exception is a severe error that will prevent further processing.
java.io.IOException - An IO exception is a severe error that will prevent further processing.

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws java.io.IOException,
                      javax.servlet.ServletException
When the browser makes a POST request, this is the method in the controller that is called.

The work of the controller will be handled by the helper. The controller will create the helper class and call its doPost method to process the request.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - Encapsulates all of the request information that is needed to communicate with the browser.
response - Encapsulates all of the response information that is needed to communicate with the browser.
Throws:
javax.servlet.ServletException - A servlet exception is a severe error that will prevent further processing.
java.io.IOException - An IO exception is a severe error that will prevent further processing.