com.go.teaservlet
Class TeaServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.go.teaservlet.TeaServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class TeaServlet
extends javax.servlet.http.HttpServlet

The TeaServlet allows Tea templates to define dynamic web pages. The URI that is passed into the servlet determines what template will be called. Within the template, custom functions can be called that return JavaBeans. These functions are accessed via Applications that are configured to run in the TeaServlet.

The TeaServlet accepts the following initialization parameters:

Version:
103 , 01/07/13
Author:
Reece Wilton
See Also:
Serialized Form

Constructor Summary
TeaServlet()
           
 
Method Summary
protected  java.lang.Object convertParameter(java.lang.String value, java.lang.Class toType)
          Converts the given HTTP parameter value to the requested type so that it can be passed directly as a template parameter.
 void destroy()
          Destroys the TeaServlet and the user's application.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process the user's http get request.
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process the user's http post request.
 java.lang.String getServletInfo()
          Returns information about the TeaServlet.
 void init(javax.servlet.ServletConfig config)
          Initializes the TeaServlet.
 
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, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeaServlet

public TeaServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the TeaServlet. Creates the logger and loads the user's application.
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - the servlet config

destroy

public void destroy()
Destroys the TeaServlet and the user's application.
Overrides:
destroy in class javax.servlet.GenericServlet

getServletInfo

public java.lang.String getServletInfo()
Returns information about the TeaServlet.
Overrides:
getServletInfo in class javax.servlet.GenericServlet

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
Process the user's http post request.
Overrides:
doPost in class javax.servlet.http.HttpServlet

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Process the user's http get request. Process the template that maps to the URI that was hit.
Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - the user's http request
response - the user's http response

convertParameter

protected java.lang.Object convertParameter(java.lang.String value,
                                            java.lang.Class toType)
Converts the given HTTP parameter value to the requested type so that it can be passed directly as a template parameter. This method is called if the template that is directly requested accepts non-String parameters, and the request provides non-null values for those parameters. The template may request an array of values for a parameter, in which case this method is called not to create the array, but rather to convert any elements put into the array.

This implementation supports converting parameters of the following types, and returns null for all others. If a conversion fails, null is returned.

When converting to Number, an instance of Integer, Long or Double is returned, depending on which parse succeeds first. A request for an Object returns either a Number or a String, depending on the success of a number parse.
Parameters:
value - non-null HTTP parameter value to convert
toType - Type to convert to
Returns:
an instance of toType or null