ch7.cookie
Class ControllerHelper

java.lang.Object
  extended by shared.HelperBaseCh4
      extended by shared.HelperBaseCh5
          extended by shared.HelperBaseCh6
              extended by ch7.cookie.ControllerHelper

public class ControllerHelper
extends HelperBaseCh6

Sets, displays and clears cookies. Some of the cookies are for a specific URL. There is no bean for this application, since it is only used to demonstrate cookies.


Nested Class Summary
 
Nested classes/interfaces inherited from class shared.HelperBaseCh4
HelperBaseCh4.SessionData
 
Field Summary
 
Fields inherited from class shared.HelperBaseCh6
checked, selected
 
Fields inherited from class shared.HelperBaseCh4
logger, request, response
 
Constructor Summary
ControllerHelper(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          The only constructor for this class has parameters for the request and response objects.
 
Method Summary
 void copyFromSession(java.lang.Object sessionHelper)
          Most of the details for retrieving data from the session are implemented in the helper base class.
 java.lang.String deleteMethod()
          The method that preforms the actions associated with the deleteCookie button.
protected  void doGet()
          This method will be called by the controller to finish processing the request.
 java.lang.String findMethod()
          The method that preforms the actions associated with the findCookie button.
protected  java.lang.String jspLocation(java.lang.String page)
          Generates the full path to a JSP.
 java.lang.String setMethod()
          The method that preforms the actions associated with the setCookie button.
 java.lang.String setSpecificMethod()
          The method that preforms the actions associated with the setSpecificCookie button.
 java.lang.String showMethod()
          The method that preforms the actions associated with the showCookie button.
 
Methods inherited from class shared.HelperBaseCh6
addChecked, addChoice, addSelected, clearMaps, clearProperty, getChecked, getSelected, invokeGetter, setCheckedAndSelected, setCheckedAndSelected
 
Methods inherited from class shared.HelperBaseCh5
getErrors, isValid, isValidProperty, setErrors
 
Methods inherited from class shared.HelperBaseCh4
addHelperToSession, addHelperToSession, doPost, executeButtonMethod, executeButtonMethod, fillBeanFromRequest, invokeButtonMethod, populateThrow, writeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerHelper

public ControllerHelper(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response)
The only constructor for this class has parameters for the request and response objects. These objects will be stored in member variables.

Parameters:
request - The object that encapsulates the request information that is needed to communicate with the browser.
response - The object that encapsulates the response information that is needed to communicate with the browser.
Method Detail

copyFromSession

public void copyFromSession(java.lang.Object sessionHelper)
Most of the details for retrieving data from the session are implemented in the helper base class. The specific details concerning the actual data must be implemented in the controller helper, since each application can have different data. The specific details are implemented in this method; it is the implementation of an abstract method in the helper base class.

In this application, the method does nothing, since there is no data associated with the application.

Specified by:
copyFromSession in class HelperBaseCh4
Parameters:
sessionHelper - The object that represents the controller helper that was added to the session in the previous request.

During each request, the controller helper is placed in the session. Before that happens, the controller helper from the previous request can be retrieved from the session. This object is retrieved in the helper base class and sent to the implementation of this abstract method.


jspLocation

protected java.lang.String jspLocation(java.lang.String page)
Generates the full path to a JSP.

Parameters:
page - The name of the JSP. This will be appended to the path of the directory that contains the JSPs. Using this method forces all the JSPs to be in the same directory.
Returns:
The string that represents the complete path to the JSP. This path must be relative to the directory where the servlet is mapped or must begin with a /, which represents the root of the web application.

showMethod

public java.lang.String showMethod()
The method that preforms the actions associated with the showCookie button. It will display all the cookies avaialable for the current URL.

Returns:
The address of the JSP that will complete the request.

setMethod

public java.lang.String setMethod()
The method that preforms the actions associated with the setCookie button. It will set a cookie that can be retrieved by all the URLs on the current server.

Returns:
The address of the JSP that will complete the request.

deleteMethod

public java.lang.String deleteMethod()
The method that preforms the actions associated with the deleteCookie button. It will look for a cookie with a given name and delete it.

Returns:
The address of the JSP that will complete the request.

findMethod

public java.lang.String findMethod()
The method that preforms the actions associated with the findCookie button. It will look for a cookie with a given name. It will add a string to the request, indicating if the cookie was found.

Returns:
The address of the JSP that will complete the request.

setSpecificMethod

public java.lang.String setSpecificMethod()
The method that preforms the actions associated with the setSpecificCookie button. This will set a cookie for the /specific.

Returns:
The address of the JSP that will complete the request.

doGet

protected void doGet()
              throws javax.servlet.ServletException,
                     java.io.IOException
This method will be called by the controller to finish processing the request. The controller is the servlet, so its doGet method will be called by the servlet engine. The controller will then call this doGet method in the helper class.

Overrides:
doGet in class HelperBaseCh4
Throws:
javax.servlet.ServletException - A servlet exception is a severe error and means that processing cannot continue.
java.io.IOException - An IO exception is a severe error and means that processing cannot continue.