|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.GenericServlet javax.servlet.http.HttpServlet org.melati.servlet.ConfigServlet org.melati.servlet.PoemServlet org.melati.servlet.TemplateServlet
public abstract class TemplateServlet
Base class to use Melati with a Template Engine.
To create your own servlet simply extend this class,
overriding the doTemplateRequest
method.
Field Summary | |
---|---|
protected ServletTemplateEngine |
templateEngine
|
Fields inherited from class org.melati.servlet.ConfigServlet |
---|
melatiConfig, sysAdminEmail, sysAdminName |
Constructor Summary | |
---|---|
TemplateServlet()
|
Method Summary | |
---|---|
protected String |
addExtension(String templateName)
The template extension is added in an overridable method to allow the application developer to specify their own template extensions. |
protected void |
doPoemRequest(Melati melati)
Override this method to build up your own output. |
protected abstract String |
doTemplateRequest(Melati melati,
ServletTemplateContext templateContext)
Override this method to build up your own output. |
void |
error(Melati melati,
Exception e)
Send an error message. |
void |
init(javax.servlet.ServletConfig config)
Inititialise the template engine. |
protected void |
prePoemSession(Melati melati)
Set the ServletTemplateEngine and ServletTemplateContext in our Melati. |
Methods inherited from class org.melati.servlet.PoemServlet |
---|
_handleException, destroy, doConfiguredRequest, getSysAdminEmail, getSysAdminName, handleException, poemContext, poemContextWithLDB |
Methods inherited from class org.melati.servlet.ConfigServlet |
---|
doGet, doPost, httpStatusCode, melatiConfig, setSysAdminEmail, setSysAdminName, writeConnectionPendingException, writeError |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
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 |
---|
protected ServletTemplateEngine templateEngine
Constructor Detail |
---|
public TemplateServlet()
Method Detail |
---|
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class ConfigServlet
config
- a ServletConfig
javax.servlet.ServletException
- if the ServletTemplateEngine has a problemprotected void prePoemSession(Melati melati) throws Exception
prePoemSession
in class PoemServlet
melati
- the current Melati
Exception
- if anything goes wrongprotected void doPoemRequest(Melati melati) throws Exception
PoemServlet
doPoemRequest
in class PoemServlet
Exception
protected String addExtension(String templateName)
To obtain nice URLs one method is to call your templates
foo.html.wm
for example, your urls can then look like
servlet/db/table/troid/method.html
.
public void error(Melati melati, Exception e)
error
in class ConfigServlet
melati
- the Melati
e
- the Exception
to reportprotected abstract String doTemplateRequest(Melati melati, ServletTemplateContext templateContext) throws Exception
melati
- the current MelatitemplateContext
- the current ServletTemplateContext
Exception
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |