groovy.servlet
Class AbstractHttpServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bygroovy.servlet.AbstractHttpServlet
All Implemented Interfaces:
ResourceConnector, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
GroovyServlet, TemplateServlet

public abstract class AbstractHttpServlet
extends javax.servlet.http.HttpServlet
implements ResourceConnector

A common ground dealing with the http servlet API wrinkles.

Author:
Christian Stein
See Also:
Serialized Form

Field Summary
static String CONTENT_TYPE_TEXT_HTML
          Content type of the HTTP response.
static String INC_PATH_INFO
          Servlet API include key name: path_info
static String INC_SERVLET_PATH
          Servlet API include key name: servlet_path
protected  javax.servlet.ServletContext servletContext
          Servlet (or the web application) context.
 
Constructor Summary
AbstractHttpServlet()
          Initializes all fields.
 
Method Summary
 URLConnection getResourceConnection(String name)
          Interface method for ResourceContainer.
protected  String getScriptUri(javax.servlet.http.HttpServletRequest request)
          Returns the include-aware uri of the script or template file.
protected  File getScriptUriAsFile(javax.servlet.http.HttpServletRequest request)
          Parses the http request for the real script or template source file.
 void init(javax.servlet.ServletConfig config)
          Overrides the generic init method.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, 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
 

Field Detail

CONTENT_TYPE_TEXT_HTML

public static final String CONTENT_TYPE_TEXT_HTML
Content type of the HTTP response.

See Also:
Constant Field Values

INC_PATH_INFO

public static final String INC_PATH_INFO
Servlet API include key name: path_info

See Also:
Constant Field Values

INC_SERVLET_PATH

public static final String INC_SERVLET_PATH
Servlet API include key name: servlet_path

See Also:
Constant Field Values

servletContext

protected javax.servlet.ServletContext servletContext
Servlet (or the web application) context.

Constructor Detail

AbstractHttpServlet

public AbstractHttpServlet()
Initializes all fields.

Method Detail

getResourceConnection

public URLConnection getResourceConnection(String name)
                                    throws ResourceException
Interface method for ResourceContainer. This is used by the GroovyScriptEngine.

Specified by:
getResourceConnection in interface ResourceConnector
Throws:
ResourceException

getScriptUri

protected String getScriptUri(javax.servlet.http.HttpServletRequest request)
Returns the include-aware uri of the script or template file.

Parameters:
request - the http request to analyze
Returns:
the include-aware uri either parsed from request attributes or hints provided by the servlet container

getScriptUriAsFile

protected File getScriptUriAsFile(javax.servlet.http.HttpServletRequest request)
Parses the http request for the real script or template source file.

Parameters:
request - the http request to analyze
Returns:
a file object using an absolute file path name

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Overrides the generic init method. Enables a fix, that tells Groovy to use (slower) reflection than compiling metaclass proxies. This is needed due to some container implementation hide their classes from the servlet by using different class loaders. See http://jira.codehaus.org/browse/GROOVY-861 for details.

Specified by:
init in interface javax.servlet.Servlet
Parameters:
config - the servlet coniguration provided by the container
Throws:
javax.servlet.ServletException - if init() method defined in super class javax.servlet.GenericServlet throws it


Copyright © 2003-2005 The Codehaus. All Rights Reserved.