|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| 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
uk.co.weft.maybeupload.MaybeUploadServlet
uk.co.weft.htform.Servlet
This is a basic servlet which produces nothing; to produce anything, specialise generateContent(). A Servlet may have a database connection -- it has all the glue. but it does not whinge if it hasn't got one. Specialised sub-classes do that whinging.
A note on the security model: this class does not currently support database level security, as connections are cached in a pool for re-use and may be re-used in other sessions with other browsers. Prepared queries are also attached to sessions in the public pool. If security is a consideration use AuthenticatedForm.
This class (and consequently all servlets which are subclasses of this class) know about the following configuration parameters:
Note that as of revision 1.24 (Jacquard 1.4.6), Servlet (and all classes inheriting from it) will support Secure Sockets Layer (HTTPS) connections, but only if you are using Java 1.4 or have JSSE loaded. If you don't, the SSL code will report this in the log on startup, but will not interfere with standard HTTP operation.
AuthenticatedForm,
Serialized Form| Field Summary | |
protected java.util.GregorianCalendar |
calendar
handy to have a calendar around to help with manipulating dates |
protected javax.servlet.ServletConfig |
conf
My configuration object, passed to me when I was created |
protected java.lang.String |
contentType
the MIME type of my content |
static java.lang.String |
CONTENTTYPECONFIGTOKEN
a configuration token on which I will seek my content type specifier in my configuraton |
protected java.lang.String |
cookieDomain
the domain for my cookies |
protected java.lang.String |
cookiePath
the path for my cookies |
static java.lang.String |
COOKIESCONFIGTOKEN
a configuration token on which I will seek the names of any initial cookies to set in my configuraton |
protected int |
cookieTTL
the default time-to-live of cookies |
protected java.lang.String |
dbPassword
and password to connect me to the database, if any |
protected java.lang.String |
dbUrl
where to find the database: there is no safe default. |
protected java.lang.String |
dbUsername
the username... |
protected boolean |
debug
print additional diagnostics on error |
static java.lang.String |
DEBUGCONFIGTOKEN
a configuration token on which I will check whether to run in debugging mode |
protected java.lang.String |
driverName
the classname of my database driver, if any |
protected boolean |
embedded
whether I am embedded in an existing (e.g. |
protected java.util.Locale |
here
where we are operating - defaults to UK english |
protected java.lang.String |
identity
my identity |
static java.lang.String |
localeMagicToken
Deprecated. use LOCALEMAGICTOKEN |
static java.lang.String |
LOCALEMAGICTOKEN
the magic token on which to store the request locale in the context, once we have computed it. |
static java.lang.String |
outputStreamMagicToken
Deprecated. use OUTPUTSTREAMMAGICTOKEN |
static java.lang.String |
OUTPUTSTREAMMAGICTOKEN
The magic token on which I store my output stream in the context |
protected Context |
parsePathInfo
a hashtable of keys I'm prepared to parse out of the path info string |
static java.lang.String |
PATHINFOMAGICTOKEN
the magic token on which I will store the path info in the context |
protected boolean |
ready
Flag to say whether second-stage initialisation is complete. |
static java.lang.String |
redirectMagicToken
Deprecated. use REDIRECTMAGICTOKEN |
static java.lang.String |
REDIRECTMAGICTOKEN
The magic token on which to store where to redirect to after a service. |
static java.lang.String |
requestMagicToken
Deprecated. use REQUESTMAGICTOKEN |
static java.lang.String |
REQUESTMAGICTOKEN
the token on which I store my request in the context |
protected java.lang.String |
resourceBundleName
the name of the resource bundle I will search for resources. |
static java.lang.String |
responseMagicToken
Deprecated. use RESPONSEMAGICTOKEN |
static java.lang.String |
RESPONSEMAGICTOKEN
the token on which I store my response in the context |
static java.lang.String |
servletMagicToken
Deprecated. use SERVLETMAGICTOKEN |
static java.lang.String |
SERVLETMAGICTOKEN
the token on which I store my servlet in the context |
static java.lang.String |
sessionMagicToken
Deprecated. use SESSIONMAGICTOKEN |
static java.lang.String |
SESSIONMAGICTOKEN
the token on which I store my session in the context |
static java.lang.String |
USEHTTPSCONFIGTOKEN
a token in which I shall look in my config for whether or not to handle HTTPS in the Servlet. |
protected java.util.TimeZone |
zone
the timezone in which we are operating -defaults to BST |
| Fields inherited from class uk.co.weft.maybeupload.MaybeUploadServlet |
allowOverwrite, maxUpload, saveUploadedFilesToDisk, silentlyRename, uploadDir, uploadDirPath, uploadDirURL |
| Fields inherited from interface uk.co.weft.htform.ResourceConsumer |
RESOURCEBUNDLEMAGICTOKEN |
| Constructor Summary | |
Servlet()
|
|
| Method Summary | |
protected void |
addCookie(java.lang.String name)
To use cookies, add named cookies using this method; do this once, at initialisation time, not each service. |
protected void |
addCookie(java.lang.String name,
int ttl)
add a new cookie with this expiration period in seconds |
protected Context |
coerceCookiesToContext(javax.servlet.http.HttpServletRequest req)
Coerce cookies from a servlet request to a context, so we can handle them generically |
protected Context |
coerceToContext(javax.servlet.http.HttpSession other)
Coerce this HTTPSession to a Context, so we can handle it generically |
protected Context |
coerceToContext(javax.servlet.ServletConfig other)
Coerce this ServletConfig to a Context, so that we can handle it generically |
protected Context |
coerceToContext(javax.servlet.ServletContext other)
This is where terminology really gets confusing, and vague names like 'context' don't really help: ServletContext is a Servlet 2.2 spec term which refers to what JServ called a servlet zone, which contains a configuration namespace, whereas our Context is just a namespace. |
protected Context |
coerceToContext(javax.servlet.ServletRequest other)
Coerce this servlet request to a Context, so we can handle it generically; if I accept values passed in the pathInfo, parse for them as well (first) |
protected java.net.URL |
coerceToUrl(java.lang.String spec)
coerce this string to a valid URL. |
protected Context |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Create a context object. |
protected void |
doGet(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse res)
Really perform service of an HTTP GET request, by printing myself on the response stream |
protected void |
doPost(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse res)
Really perform service of an HTTP POST request, by printing myself on the response stream |
protected Context |
fixupMagicValues(Context context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Fix up the magic values stored on the context by this class. |
protected abstract void |
generateContent(Context context)
Specialise! Do not use! Output the whole document including headers |
java.util.Calendar |
getCalendar()
Return my calendar, surprisingly enough; this contains my localisation stuff. |
protected java.lang.String |
getContentType(Context context)
Return my content type in this context. |
boolean |
getDebug()
|
java.util.Locale |
getLocale(Context context)
get the client-side locale if it can be deduced from the context, else server side. |
javax.servlet.ServletOutputStream |
getOutputStream(Context context)
a convenience method for getting hold of the ServletOutputStream I should have put into the context -- asuming this context is mine, of course |
java.lang.Object |
getResource(java.lang.String key,
Context context)
Deprecated. i18n code is still experimental and the only call I commit to supporting in the longer term is grs(String,Context) |
java.lang.String |
getResourceString(java.lang.String key,
Context context)
Deprecated. i18n code is still experimental and the only call I commit to supporting in the longer term is grs(String,Context) |
java.lang.String |
getServletInfo()
tell the world about me. |
java.lang.String |
grs(java.lang.String key)
Deprecated. use grs(String,Context) |
java.lang.String |
grs(java.lang.String key,
Context context)
shorthand for getResourceString; identical to it. |
protected void |
handleAction(Context context)
Intended to handle actions implied by the context before the page is served; for example, different submit buttons with different actions. |
protected void |
handleCookies(Context context)
Sort out the business of sending and receiving cookies |
boolean |
handleRedirect(Context context)
Set up redirect headers if context contains a valid URL as the value of redirectMagicToken; return true in this case. |
void |
init(Context config)
Basic initialisation, taking my configuration from this Context |
void |
init(javax.servlet.ServletConfig config)
Initialisation: Set up my variables from my configuration. |
protected void |
makeReady(Context context)
Second-stage initialisation hook. |
protected void |
outputRedirectBlock(Context context)
Possibly output a stub HTML page with a 'refresh' meta. |
void |
setCookieValues(Context context)
To use cookies, add named cookies using addCookie(); do this once, at initialisation time, not each service. |
protected void |
storeOnSession(Context context,
java.lang.String key,
java.lang.String value)
Deprecated. still experimental; may not be supported in future |
protected void |
whinge(javax.servlet.ServletOutputStream out,
java.lang.Exception e)
Deprecated. you really, really ought to be passing a context |
protected void |
whinge(javax.servlet.ServletOutputStream out,
java.lang.Exception e,
Context context)
Last line-of-defence error reporter. |
| Methods inherited from class uk.co.weft.maybeupload.MaybeUploadServlet |
doDelete, doHead, doOptions, doPut, doTrace, getUploadDir, getUploadURL, service |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, 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 CONTENTTYPECONFIGTOKEN
public static final java.lang.String COOKIESCONFIGTOKEN
public static final java.lang.String DEBUGCONFIGTOKEN
public static final java.lang.String LOCALEMAGICTOKEN
public static final java.lang.String OUTPUTSTREAMMAGICTOKEN
public static final java.lang.String PATHINFOMAGICTOKEN
public static final java.lang.String REDIRECTMAGICTOKEN
public static final java.lang.String REQUESTMAGICTOKEN
public static final java.lang.String RESPONSEMAGICTOKEN
public static final java.lang.String SERVLETMAGICTOKEN
public static final java.lang.String SESSIONMAGICTOKEN
public static final java.lang.String USEHTTPSCONFIGTOKEN
public static final java.lang.String requestMagicToken
public static final java.lang.String responseMagicToken
public static final java.lang.String servletMagicToken
public static final java.lang.String sessionMagicToken
public static final java.lang.String outputStreamMagicToken
public static final java.lang.String redirectMagicToken
public static final java.lang.String localeMagicToken
protected Context parsePathInfo
protected java.util.GregorianCalendar calendar
protected java.util.Locale here
protected javax.servlet.ServletConfig conf
protected java.lang.String contentType
protected java.lang.String cookieDomain
protected java.lang.String cookiePath
protected java.lang.String dbPassword
protected java.lang.String dbUrl
protected java.lang.String dbUsername
protected java.lang.String driverName
protected java.lang.String identity
protected java.lang.String resourceBundleName
protected java.util.TimeZone zone
protected boolean debug
protected boolean embedded
protected boolean ready
protected int cookieTTL
| Constructor Detail |
public Servlet()
| Method Detail |
public java.util.Calendar getCalendar()
public void setCookieValues(Context context)
context - the context in which the cookie values will be set.public boolean getDebug()
public java.util.Locale getLocale(Context context)
public javax.servlet.ServletOutputStream getOutputStream(Context context)
context - the context to look in for the stream
public java.lang.Object getResource(java.lang.String key,
Context context)
getResource in interface ResourceConsumerkey - the key to search forcontext - teh context in which to make request; may contain locale
information
public java.lang.String getResourceString(java.lang.String key,
Context context)
getResourceString in interface ResourceConsumerkey - the key to search forcontext - the context in which to make this call (may contain
locale information)
public java.lang.String getServletInfo()
getServletInfo in interface javax.servlet.Servlet
public java.lang.String grs(java.lang.String key,
Context context)
grs in interface ResourceConsumer#getResourceString(String)public java.lang.String grs(java.lang.String key)
grs in interface ResourceConsumer
public boolean handleRedirect(Context context)
throws java.net.MalformedURLException,
java.io.IOException
context - the context for this service
java.io.IOException - may be passed through from outputRedirectBlock
java.net.MalformedURLException - if value of redirectMagicToken in
context is not a valid (relative) URL
public final void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class MaybeUploadServletconfig - my Servlet configuration.
javax.servlet.ServletException - doesn't; thing which specialise me may
public void init(Context config)
throws InitialisationException
InitialisationExceptionprotected java.lang.String getContentType(Context context)
protected void addCookie(java.lang.String name)
name - the name of the cookie to set - also, the name which
contexts will be searched on to provide the cookie value.
protected void addCookie(java.lang.String name,
int ttl)
name - the name of the cookie to set - also, the name which
contexts will be searched on to provide the cookie value.ttl - time to live for this cookie in seconds.protected Context coerceCookiesToContext(javax.servlet.http.HttpServletRequest req)
req - the ServletRequest to coerce.
protected Context coerceToContext(javax.servlet.ServletContext other)
other - the ServletContext to coerce.
Mapprotected Context coerceToContext(javax.servlet.ServletConfig other)
other - the ServletConfig to coerce.
protected Context coerceToContext(javax.servlet.http.HttpSession other)
throws javax.servlet.ServletException
other - the HttpSession to coerce.
javax.servlet.ServletException
protected Context coerceToContext(javax.servlet.ServletRequest other)
throws javax.servlet.ServletException
other - the ServletRequest to coerce.
javax.servlet.ServletException
protected Context createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws DataStoreException,
javax.servlet.ServletException
Note that it is this class which establishes the precedence (masking) of values as they appear in the context, namely:
request - the request object for this serviceresponse - the response object for this service
No - , I know this doesn't actually throw an exception. But
things which specialise me may want to.
DataStoreException
javax.servlet.ServletExceptionfixupMagicValues(uk.co.weft.dbutil.Context, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected Context fixupMagicValues(Context context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
context - the context in which the values are to be fixedrequest - the request for this serviceresponse - the response to this request
protected abstract void generateContent(Context context)
throws java.lang.Exception
context - the context in which to generate this content.
java.lang.Exception
protected java.net.URL coerceToUrl(java.lang.String spec)
throws java.net.MalformedURLException
spec - a string representing a URL or a full or relative file path
name; if relative, relative to the document root of my web-app.
java.net.MalformedURLException - if the string cannot be coerced to a
valid URL
protected void doGet(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
java.io.IOException
doGet in class MaybeUploadServletreq - the request object for this serviceres - the response object for this service
javax.servlet.ServletException
java.io.IOException
protected void doPost(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class MaybeUploadServletreq - a request wrapper which know how to handle uploadres - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void handleAction(Context context)
throws java.lang.Exception
context - the context for this service.
doesn - 't actually throw an exception but things which
specialise it may want to
java.lang.ExceptionForm.handleAction(uk.co.weft.dbutil.Context)
protected void handleCookies(Context context)
throws javax.servlet.ServletException,
java.io.IOException
context - the context for this service, from which cookie values
will be read and into which cookie values will be set.
javax.servlet.ServletException
java.io.IOException
protected void makeReady(Context context)
throws DataStoreException,
javax.servlet.ServletException
context - my first context.
Specialisations - may want to throw exceptions for various
reasons, which is why the possibility of a ServletException
or DataStoreException is provided for.
DataStoreException
javax.servlet.ServletException
protected void outputRedirectBlock(Context context)
throws java.io.IOException
context - the context for this service
java.io.IOException - if output barfs.
protected void storeOnSession(Context context,
java.lang.String key,
java.lang.String value)
throws DataStoreException
context - the context in which this is being passed aroundkey - the key against which the value should be storedvalue - the value to store
DataStoreException - if no session can be found; may become
more specialised exception in mature implementation
protected void whinge(javax.servlet.ServletOutputStream out,
java.lang.Exception e,
Context context)
throws javax.servlet.ServletException
out - an output stream to print one - an exception to whinge aboutcontext - the context in which the problem occurred.
javax.servlet.ServletException
protected void whinge(javax.servlet.ServletOutputStream out,
java.lang.Exception e)
throws javax.servlet.ServletException,
java.io.IOException
out - an output stream to print one - an exception to whinge about
javax.servlet.ServletException
java.io.IOException
|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||