toolbox.web
Class ControllerServlet

Package class diagram package ControllerServlet
java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by toolbox.web.ControllerServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, Controller

public class ControllerServlet
extends javax.servlet.http.HttpServlet
implements Controller

Front Controller servlet for developing web applications.

The servlet functions as a controller for all the actions defined in the web_config.xml file.

Requests to this servlet take the following form: http://server/your_app/controller?[action=<action>][template=<tmpl_name>]

See Also:
Serialized Form

Constructor Summary
ControllerServlet()
          Default constructor
 
Method Summary
 void destroy()
          Destroy the servlet.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles all HTTP GET requests.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles all HTTP POST requests.
 XMLProperties getConfiguration()
          Return the XML configuration properties of this controller.
 java.util.Map getProperties()
          Return the global configuration properties as a map.
 java.lang.String getResource()
          Return the name of the resource configured for this controller.
 Validator getValidator(java.lang.String name)
          Return the named Validator instance.
 void init(javax.servlet.ServletConfig config)
          Initialise the ControllerServlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
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

ControllerServlet

public ControllerServlet()
Default constructor

Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialise the ControllerServlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - Servlet configuration properties.
Throws:
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Handles all HTTP GET requests.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - GET request.
response - Response channel.
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Handles all HTTP POST requests.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - GET request.
response - Response channel.
Throws:
javax.servlet.ServletException
java.io.IOException

getConfiguration

public XMLProperties getConfiguration()
Return the XML configuration properties of this controller.

Specified by:
getConfiguration in interface Controller
Returns:
XMLProperties instance.

getValidator

public Validator getValidator(java.lang.String name)
Return the named Validator instance.

Specified by:
getValidator in interface Controller
Parameters:
name - String containing name of Validator to return.
Returns:
Validator instance.,

getProperties

public java.util.Map getProperties()
Return the global configuration properties as a map.

Specified by:
getProperties in interface Controller
Returns:
Map instance containing the global configuration properties.

getResource

public java.lang.String getResource()
Return the name of the resource configured for this controller.

Specified by:
getResource in interface Controller
Returns:
String containing the name of the resource configured for this controller.

destroy

public void destroy()
Destroy the servlet.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet