org.szegedi.expose.servlet
Class ExposeServlet
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--org.szegedi.expose.servlet.ExposeServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class ExposeServlet
- extends javax.servlet.http.HttpServlet
This is a general-purpose Freemarker servlet with following features:
- It utilizes a TemplateCache that is fully parametrizable
- It makes all request, request parameters, session, and servlet
context attributes available to templates through "Request", "RequestParameters",
"Session", and "Application" variables. The implementation for these variables
is efficient; rather than copying the attributes and parameters into SimpleHash,
special wrapper classes are used that implement the
TemplateHashModel
interface.
Supported initialization parameters are:
- TemplatePath specifies the location of the templates.
By default, the location is the web application-relative URI of
the location. Alternatively, you can prepend it with file:// to
indicate path in the file system (i.e. file:///var/www/project/templates/).
Note that three slashes were specified.
Default value is / (that is, the root of the web application).
- TemplateUpdateInterval value for update interval of the
template cache in milliseconds. Default is 60000 (ten minutes)
- NoCache if set to true, generates headers in the response
that advise the HTTP client not to cache the returned page. Default false
- Version:
- 1.0
- Author:
- Attila Szegedi, attila@szegedi.org
- See Also:
- Serialized Form
|
Method Summary |
protected freemarker.template.TemplateCache |
createCache()
|
protected HttpRequestParametersHashModel |
createRequestParametersHashModel(javax.servlet.http.HttpServletRequest request)
|
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
init()
|
protected void |
initializeServletContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Called when servlet detects in a request processing that
application-global (that is, ServletContext-specific) attributes are not yet
set.
|
protected void |
initializeSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Called when servlet detects in a request processing that
session-global (that is, HttpSession-specific) attributes are not yet
set.
|
protected void |
postTemplateProcess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
freemarker.template.Template template,
freemarker.template.TemplateModelRoot data)
Called after the execution returns from template.process().
|
protected boolean |
preTemplateProcess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
freemarker.template.Template template,
freemarker.template.TemplateModelRoot data)
Called before the execution is passed to template.process().
|
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, 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 |
serialVersionUID
public static final long serialVersionUID
debug
protected boolean debug
ExposeServlet
public ExposeServlet()
init
public void init()
- Overrides:
init in class javax.servlet.GenericServlet
createCache
protected freemarker.template.TemplateCache createCache()
doGet
public 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
doPost
public 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
createRequestParametersHashModel
protected HttpRequestParametersHashModel createRequestParametersHashModel(javax.servlet.http.HttpServletRequest request)
initializeServletContext
protected void initializeServletContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
- Called when servlet detects in a request processing that
application-global (that is, ServletContext-specific) attributes are not yet
set.
This is a generic hook you might use in subclasses to perform a specific
action on first request in the context. By default it does nothing.
- Parameters:
request - the actual HTTP requestresponse - the actual HTTP response
initializeSession
protected void initializeSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
- Called when servlet detects in a request processing that
session-global (that is, HttpSession-specific) attributes are not yet
set.
This is a generic hook you might use in subclasses to perform a specific
action on first request in the session. By default it does nothing.
- Parameters:
request - the actual HTTP requestresponse - the actual HTTP response
preTemplateProcess
protected boolean preTemplateProcess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
freemarker.template.Template template,
freemarker.template.TemplateModelRoot data)
throws javax.servlet.ServletException,
java.io.IOException
- Called before the execution is passed to template.process().
This is a generic hook you might use in subclasses to perform a specific
action before the template is processed. By default does nothing.
A typical action to perform here is to inject application-specific
objects into the TemplateModelRoot.
- Parameters:
request - the actual HTTP requestresponse - the actual HTTP responsetemplate - the template that will get executeddata - the data that will be passed to the template- Returns:
- true to process the template, false to suppress template processing.
postTemplateProcess
protected void postTemplateProcess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
freemarker.template.Template template,
freemarker.template.TemplateModelRoot data)
throws javax.servlet.ServletException,
java.io.IOException
- Called after the execution returns from template.process().
This is a generic hook you might use in subclasses to perform a specific
action after the template is processed. It will be invoked even if the
template processing throws an exception. By default does nothing.
- Parameters:
request - the actual HTTP requestresponse - the actual HTTP responsetemplate - the template that was executeddata - the data that was passed to the template