public class ConfluenceVelocityServlet
extends javax.servlet.http.HttpServlet
We have copied code here because we can't override the WebWorkVelocityServlet as it calls VelocityServlet.init() which loads _another_ entire identical instance of Velocity (beyond the VelocityManager's instance), and the two are used interchangeably.
http://jira.atlassian.com/browse/CONF-6355
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONTENT_TYPE
The default content type for the response
|
Constructor and Description |
---|
ConfluenceVelocityServlet() |
Modifier and Type | Method and Description |
---|---|
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 all requests
|
protected void |
error(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Exception cause)
Invoked when there is an error thrown in any part of doRequest() processing.
|
protected String |
getEncoding() |
org.apache.velocity.Template |
getTemplate(String name,
String encoding)
Retrieves the requested template with the specified
character encoding.
|
protected org.apache.velocity.Template |
handleRequest(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse,
org.apache.velocity.context.Context context) |
void |
init(javax.servlet.ServletConfig servletConfig) |
protected void |
mergeTemplate(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
javax.servlet.http.HttpServletResponse response)
Copy of the method from WebworkVelocityServlet, adding a flush for the writer to get around problems we
were having with truncated content when a filter started talking directly to the servletresponse writer
without the webwork writer having been flushed in the meanwhile.
|
protected void |
setContentType(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sets the content type of the response.
|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
public static final String DEFAULT_CONTENT_TYPE
public void init(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
protected org.apache.velocity.context.Context createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected org.apache.velocity.Template handleRequest(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, org.apache.velocity.context.Context context) throws Exception
Exception
protected String getEncoding()
public org.apache.velocity.Template getTemplate(String name, String encoding) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, Exception
name
- The file name of the template to retrieve relative to the
template root.encoding
- the character encoding of the templateorg.apache.velocity.exception.ResourceNotFoundException
- if template not found
from any available source.org.apache.velocity.exception.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.Exception
- if an error occurs in template initializationpublic void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
doPost
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
protected void doRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
request
- HttpServletRequest object containing client requestresponse
- HttpServletResponse object for the responsejavax.servlet.ServletException
IOException
protected void setContentType(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
The default implementation is :
response.setContentType( defaultContentType );
where defaultContentType is set to the value of the default.contentType property, or "text/html" if that is not set.
request
- servlet request from clientresponse
- servlet reponse to clientprotected void mergeTemplate(org.apache.velocity.Template template, org.apache.velocity.context.Context context, javax.servlet.http.HttpServletResponse response) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, org.apache.velocity.exception.MethodInvocationException, IOException, UnsupportedEncodingException, Exception
TODO: When this gets fixed in WebWork, remove this method.
org.apache.velocity.exception.ResourceNotFoundException
org.apache.velocity.exception.ParseErrorException
org.apache.velocity.exception.MethodInvocationException
IOException
UnsupportedEncodingException
Exception
protected void error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception cause) throws javax.servlet.ServletException, IOException
request
- original HttpServletRequest from servlet container.response
- HttpServletResponse object from servlet container.cause
- Exception that was thrown by some other part of process.javax.servlet.ServletException
IOException
Copyright © 2003–2017 Atlassian. All rights reserved.