org.apache.commons.jelly.servlet
Class JellyServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.commons.jelly.servlet.JellyServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class JellyServlet
extends javax.servlet.http.HttpServlet

Servlet for handling display of Jelly-fied XML files. Modelled after VelocityServlet.

Version:
$Revision: 1807798 $
Author:
Kelvin Tan
See Also:
Serialized Form

Field Summary
static java.lang.String REQUEST
          The HTTP request object context key.
static java.lang.String RESPONSE
          The HTTP response object context key.
 
Constructor Summary
JellyServlet()
           
 
Method Summary
protected  JellyContext createContext(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void doRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Handles all requests
protected  void error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception cause)
          Invoked when there is an error thrown in any part of doRequest() processing.
protected  java.net.URL getScript(javax.servlet.http.HttpServletRequest req)
           Either use the query parameter "script", or the URI itself to denote the script to run.
protected  void runScript(java.net.URL script, JellyContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
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, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST

public static final java.lang.String REQUEST
The HTTP request object context key.

See Also:
Constant Field Values

RESPONSE

public static final java.lang.String RESPONSE
The HTTP response object context key.

See Also:
Constant Field Values
Constructor Detail

JellyServlet

public JellyServlet()
Method Detail

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doRequest

protected void doRequest(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Handles all requests

Parameters:
req - HttpServletRequest object containing client request
res - HttpServletResponse object for the response
Throws:
javax.servlet.ServletException
java.io.IOException

createContext

protected JellyContext createContext(javax.servlet.http.HttpServletRequest req,
                                     javax.servlet.http.HttpServletResponse res)
Parameters:
req -
res -
Returns:
See Also:
org.apache.velocity.servlet.VelocityServlet#createContext

getScript

protected java.net.URL getScript(javax.servlet.http.HttpServletRequest req)
                          throws java.net.MalformedURLException

Either use the query parameter "script", or the URI itself to denote the script to run.

Example: script=index.jelly or http://localhost:8080/foo/index.jelly.

Parameters:
req -
Returns:
Throws:
java.net.MalformedURLException
See Also:
org.apache.velocity.servlet.VelocityServlet#getTemplate

runScript

protected void runScript(java.net.URL script,
                         JellyContext context,
                         javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws java.io.IOException,
                         java.io.UnsupportedEncodingException,
                         JellyException
Parameters:
script -
context -
req -
res -
Throws:
java.io.IOException
java.io.UnsupportedEncodingException
JellyException
See Also:
org.apache.velocity.servlet.VelocityServlet#mergeTemplate

error

protected void error(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     java.lang.Exception cause)
              throws javax.servlet.ServletException,
                     java.io.IOException
Invoked when there is an error thrown in any part of doRequest() processing.

Default will send a simple HTML response indicating there was a problem.

Ripped from VelocityServlet.

Parameters:
request - original HttpServletRequest from servlet container.
response - HttpServletResponse object from servlet container.
cause - Exception that was thrown by some other part of process.
Throws:
javax.servlet.ServletException
java.io.IOException