|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.apache.velocity.tools.view.VelocityViewServlet
public class VelocityViewServlet
A servlet to process Velocity templates. This is comparable to the the JspServlet for JSP-based applications.
The servlet provides the following features:
VelocityViewServlet supports the following configuration parameters in web.xml:
true
. If set to false
, then
the VelocityView
used by this servlet will not be shared
with other VelocityViewServlets or VelocityViewTag
s in the
application.true
. If set to false
, then
the default toolbox configuration will not be added to your (if any)
custom configuration. NOTE: The default configuration will also be
suppressed if you are using a deprecated toolbox.xml format and do not
explicitly set this to true
.false
. If set to true
, then
then the final toolbox configuration (the combination of any custom
one(s) provided by yourself and/or the default configuration(s))
will have all invalid tools, properties, and/or data removed prior to
configuring the ToolboxFactory for this servlet by a
ConfigurationCleaner
Field Summary | |
---|---|
private static long |
serialVersionUID
|
static java.lang.String |
SHARED_CONFIG_PARAM
|
private VelocityView |
view
|
Constructor Summary | |
---|---|
VelocityViewServlet()
|
Method Summary | |
---|---|
protected org.apache.velocity.context.Context |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handles GET - calls doRequest() |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle a POST request - calls doRequest() |
protected void |
doRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handles with both GET and POST requests |
protected void |
error(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Throwable e)
Invoked when there is an error thrown in any part of doRequest() processing. |
protected void |
fillContext(org.apache.velocity.context.Context context,
javax.servlet.http.HttpServletRequest request)
|
protected java.lang.String |
findInitParameter(javax.servlet.ServletConfig config,
java.lang.String key)
Looks up an init parameter with the specified key in either the ServletConfig or, failing that, in the ServletContext. |
protected org.apache.velocity.runtime.log.Log |
getLog()
|
protected org.apache.velocity.Template |
getTemplate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected org.apache.velocity.Template |
getTemplate(java.lang.String name)
|
protected java.lang.String |
getVelocityProperty(java.lang.String name,
java.lang.String alternate)
|
protected VelocityView |
getVelocityView()
|
void |
init(javax.servlet.ServletConfig config)
Initializes servlet and VelocityView used to process requests. |
protected void |
mergeTemplate(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
javax.servlet.http.HttpServletResponse response)
|
protected void |
requestCleanup(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.apache.velocity.context.Context context)
Cleanup routine called at the end of the request processing sequence allows a derived class to do resource cleanup or other end of process cycle tasks. |
protected void |
setContentType(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sets the content type of the response. |
protected void |
setVelocityView(VelocityView view)
|
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, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SHARED_CONFIG_PARAM
private static final long serialVersionUID
private VelocityView view
Constructor Detail |
---|
public VelocityViewServlet()
Method Detail |
---|
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
Initializes servlet and VelocityView used to process requests. Called by the servlet container on loading.
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
config
- servlet configuation
javax.servlet.ServletException
protected java.lang.String findInitParameter(javax.servlet.ServletConfig config, java.lang.String key)
protected void setVelocityView(VelocityView view)
protected VelocityView getVelocityView()
protected java.lang.String getVelocityProperty(java.lang.String name, java.lang.String alternate)
protected org.apache.velocity.runtime.log.Log getLog()
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doPost
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
protected void doRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- HttpServletRequest object containing client requestresponse
- HttpServletResponse object for the responseprotected org.apache.velocity.context.Context createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected void fillContext(org.apache.velocity.context.Context context, javax.servlet.http.HttpServletRequest request)
protected void setContentType(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
The default implementation is :
response.setContentType(view.getDefaultContentType());
where defaultContentType is set to the value of the default.contentType
property, or "text/html" if that was not set for the VelocityView
.
request
- servlet request from clientresponse
- servlet reponse to clientprotected org.apache.velocity.Template getTemplate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected org.apache.velocity.Template getTemplate(java.lang.String name)
protected void mergeTemplate(org.apache.velocity.Template template, org.apache.velocity.context.Context context, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
java.io.IOException
protected void error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Throwable e)
request
- original HttpServletRequest from servlet container.response
- HttpServletResponse object from servlet container.e
- Exception that was thrown by some other part of process.protected void requestCleanup(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.velocity.context.Context context)
request
- servlet request from clientresponse
- servlet responsecontext
- Context that was merged with the requested template
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |