|
Purple Code | |||||||||
| 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
|
+--com.purpletech.servlets.DefaultServlet
A servlet that keeps its own list of default parameters, which it uses in case a requested parameter was unspecified by the user or the sysadmin. It uses the same list for page params and init params.
It also overrides log() to stash the messages in a private string buffer. Subclasses can access this with the getLog() and getLogHTML() methods. The idea is that during development, servlets may want to output the logs directly on each page request (so the developer doesn't have to go looking in the file system for a log file that probably wasn't flushed anyway).
| Field Summary | |
protected java.lang.StringBuffer |
logBuffer
|
| Constructor Summary | |
DefaultServlet()
|
|
| Method Summary | |
java.lang.String |
getInitParameter(java.lang.String name)
Overrides standard getInitParameter. |
java.lang.String |
getLog()
|
java.lang.String |
getLogHTML()
|
java.lang.String |
getParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String name)
Overrides standard getParameter. |
java.lang.String |
getServletInfo()
|
void |
log(java.lang.String s)
|
void |
log(java.lang.Throwable t)
|
protected void |
setDefaults(java.util.Dictionary d)
Set the list of default parameters. |
protected void |
setDefaults(java.lang.String[][] d)
Set the list of default parameters. |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.StringBuffer logBuffer
| Constructor Detail |
public DefaultServlet()
| Method Detail |
public java.lang.String getParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String name)
public java.lang.String getInitParameter(java.lang.String name)
getInitParameter in interface javax.servlet.ServletConfiggetInitParameter in class javax.servlet.GenericServletprotected void setDefaults(java.util.Dictionary d)
d - the name-value pairsprotected void setDefaults(java.lang.String[][] d)
Subclasses need to call this method in their
init() method. For example:
String[][] defaults = { {"username", "bodiddley" }
{"password", "lovehate" }
{"datasource", "jdbc:odbc:MyData" }
};
public void init(ServletConfig cfg) {
super.init(cfg);
setDefaults(defaults);
}
(Note that it's OK to name your variable
defaults too because this class' variable is
private, hence shadowed in subclasses.)
If you have multiple levels of subclasses, just make sure
you call super.init(cfg) at the top of your
init() method (before you call
setDefaults(). That way, the superclass will set
its defaults, then you can set yours (and possibly override the
superclass' values).
d - the name-value pairspublic void log(java.lang.String s)
log in class javax.servlet.GenericServletpublic void log(java.lang.Throwable t)
public java.lang.String getLog()
public java.lang.String getLogHTML()
public java.lang.String getServletInfo()
getServletInfo in interface javax.servlet.ServletgetServletInfo in class javax.servlet.GenericServlet
|
Documentation generated March 5 2003 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||