|
||||||||||
| 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
lazyj.ExtendedServlet
public abstract class ExtendedServlet
Probably the most important class in the world :)
This class is a wrapper over the original HttpServlet, adding caching and run time limit for the servlets.
There are also other useful functions, like initMultipartRequest(String, int) for uploading files,
getX (s/i/f/d) for parsing the parameters and getting the correct value, getCookie(String),
setCookie(String, String), log(int, String)
RequestWrapper,
Serialized Form| Field Summary | |
|---|---|
protected boolean |
bGet
Servlets can treat GET and POST differently based on the method they override or by looking at this variable |
protected boolean |
bRedirect
Remember whether or not there was a redirect executed by the servlet |
DBSession |
dbs
Current session |
static long |
lServerStarted
This is when the server was started |
protected com.oreilly.servlet.MultipartRequest |
mpRequest
Object used for file uploading. |
protected java.io.OutputStream |
osOut
OutputStream to the client |
protected java.io.PrintWriter |
pwOut
PrintWriter to the client. |
protected javax.servlet.http.HttpServletRequest |
request
The original request object |
protected javax.servlet.http.HttpServletResponse |
response
The original response object |
protected java.lang.String |
sPage
Current servlet that is executed |
protected java.lang.String |
sZone
The zone of the currently executed servlet |
| Constructor Summary | |
|---|---|
ExtendedServlet()
|
|
| Method Summary | |
|---|---|
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Original request from servlet engine comes through here. |
protected void |
doInit()
This is a hook provided for the servlets as a generic way to initialize their local variables, do authentication and so on. |
void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Original request from servlet engine comes through here. |
static java.lang.String |
esc(java.lang.String s)
Produce safe SQL strings. |
static java.lang.String |
escHtml(java.lang.String s)
Produce save HTML strings. |
abstract void |
execGet()
A servlet must implement at least this method. |
void |
execPost()
By default POST request are executed with the same execGet() function. |
protected int |
getApp()
Get the application number. |
static long |
getCacheAccesses()
Statistics: get the total number of accesses to pages that could be cached |
static long |
getCacheHits()
Statistics: get the number of cache hits |
protected java.lang.String |
getCacheKeyModifier()
Override this method to return any value that would alter the cache. |
protected long |
getCacheTimeout()
Method to specify the maximum life time of the cached contents. |
java.lang.String |
getCookie(java.lang.String sName)
Get the value of a specific cookie |
java.lang.String |
getCurrentPage()
Compose the full URL to the current page. |
double |
getd(java.lang.String sParam)
Get the value of a parameter as a double value. |
double |
getd(java.lang.String sParam,
double defaultVal)
Get the value of a parameter as a double value. |
protected java.lang.String |
getDomain()
Method to specify the domain for which the cookies will be set by default (session cookie included). |
float |
getf(java.lang.String sParam)
Get the value of a parameter as a float value. |
float |
getf(java.lang.String sParam,
float defaultVal)
Get the value of a parameter as a float value. |
static long |
getFrameworkRequests()
Framework statistics: get the total number of requests serviced by the framework. |
java.lang.String |
getHostAddr()
Get the client host address (IP). |
java.lang.String |
getHostName()
Get the nice host name for the client that made the current request. |
int |
geti(java.lang.String sParam)
Get the value of a parameter as an integer value. |
int |
geti(java.lang.String sParam,
int defaultVal)
Get the value of a parameter as an integer value. |
long |
getl(java.lang.String sParam)
Get the value of a parameter as a long value. |
long |
getl(java.lang.String sParam,
long defaultVal)
Get the value of a parameter as a long value. |
protected int |
getMaxRunTime()
Method to specify the maximum run time for a page. |
protected int |
getOnlineUsers()
Get the number of online users for the current application. |
java.lang.String |
gets(java.lang.String sParam)
Get the value of a parameter as a string. |
java.lang.String |
gets(java.lang.String sParam,
java.lang.String sDefault)
Get the value of a parameter as a string. |
static java.lang.String |
getServerUptime()
Statistics: get the server uptime |
java.lang.String[] |
getValues(java.lang.String sParam)
Get all the values of a parameter. |
protected boolean |
initMultipartRequest(java.lang.String sTempDir,
int iFileSizeLimit)
This method should be called when the servlet expects a file upload from the client. |
boolean |
isLoggable(int iLevel)
Find out whether or not the current page is able to log this level of debug. |
boolean |
isSessionIPProtected()
Flag to set whether or not the session is valid only when used from the first IP that generated the session. |
void |
log(int level,
java.lang.String sMessage)
Log messages with a given level of the problem. |
void |
log(int level,
java.lang.String sMessage,
java.lang.Object o)
Special logging for exceptions. |
void |
log(java.lang.String sMessage)
Override the method provided by the Java Servlet Api to log messages as DEBUG |
protected boolean |
redirect(java.lang.String sURL)
Wrapper method for the actual redirect, that keeps track if there was such an opperation. |
void |
setContentType(java.lang.String sContentType)
If you set the content type to something else than "text/html; charset=UTF-8" and you use the caching mechanism you should use this method instead of directly calling response.setContentType |
boolean |
setCookie(java.lang.String sName,
java.lang.String sValue)
Send a session cookie to the browser. |
boolean |
setCookie(java.lang.String sName,
java.lang.String sValue,
int iAge)
Send a cookie to the browser. |
boolean |
setCookie(java.lang.String sName,
java.lang.String sValue,
java.lang.String sDomain,
int iAge)
Send a cookie to the browser. |
protected void |
zoneInit()
Override this function to initialize local servlet or zone variables (pMaster for example) |
| 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, init |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long lServerStarted
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
protected java.io.OutputStream osOut
protected java.io.PrintWriter pwOut
protected java.lang.String sPage
protected java.lang.String sZone
protected com.oreilly.servlet.MultipartRequest mpRequest
initMultipartRequest(String, int).
protected boolean bRedirect
protected boolean bGet
public DBSession dbs
| Constructor Detail |
|---|
public ExtendedServlet()
| Method Detail |
|---|
protected java.lang.String getCacheKeyModifier()
public static final long getCacheAccesses()
public static final long getCacheHits()
public static final java.lang.String getServerUptime()
public static final long getFrameworkRequests()
protected long getCacheTimeout()
protected java.lang.String getDomain()
protected int getMaxRunTime()
public abstract void execGet()
public void execPost()
execGet() function.
If you want to execute a different code on POST than on GET you can override this
function or you can check the bGet variable.
protected int getApp()
getOnlineUsers() for example.
public boolean isSessionIPProtected()
public void setContentType(java.lang.String sContentType)
response.setContentType
sContentType - public final java.lang.String gets(java.lang.String sParam)
sParam - the parameter name
public final java.lang.String gets(java.lang.String sParam,
java.lang.String sDefault)
sParam - the parameter namesDefault - default value to return in case the value is not defined or is the empty string
public final int geti(java.lang.String sParam,
int defaultVal)
sParam - the name of the parameterdefaultVal - default value to return in case of an error
public final int geti(java.lang.String sParam)
sParam - name of the parameter
public final long getl(java.lang.String sParam,
long defaultVal)
sParam - the name of the parameterdefaultVal - default value to return in case of an error
public final long getl(java.lang.String sParam)
sParam - name of the parameter
public final float getf(java.lang.String sParam,
float defaultVal)
sParam - the name of the parameterdefaultVal - default value to return in case of an error
public final float getf(java.lang.String sParam)
sParam - name of the parameter
public final double getd(java.lang.String sParam,
double defaultVal)
sParam - the name of the parameterdefaultVal - default value to return in case of an error
public final double getd(java.lang.String sParam)
sParam - name of the parameter
public final java.lang.String[] getValues(java.lang.String sParam)
sParam -
protected final boolean redirect(java.lang.String sURL)
sURL - the URL to send the browser to
public static final java.lang.String esc(java.lang.String s)
Format.escSQL(String) call.
s - the string to escape
public static final java.lang.String escHtml(java.lang.String s)
Format.escHtml(String) call.
s - the string to escape
public final java.lang.String getCookie(java.lang.String sName)
sName - the name of the cookie
public boolean setCookie(java.lang.String sName,
java.lang.String sValue)
getDomain() function
sName - name of the cookiesValue - value
public boolean setCookie(java.lang.String sName,
java.lang.String sValue,
int iAge)
getDomain() function
sName - name of the cookiesValue - valueiAge - lifetime of the cookie, in seconds, relative to "now". Negative=session cookie. Zero=delete this cookie.
public boolean setCookie(java.lang.String sName,
java.lang.String sValue,
java.lang.String sDomain,
int iAge)
sName - name of the cookiesValue - valuesDomain - the domain for which this cookie is setiAge - lifetime of the cookie, in seconds, relative to "now". Negative=session cookie. Zero=delete this cookie.
protected void doInit()
getCacheTimeout() and getCacheKeyModifier().
For IO-related variables (eg pMaster) use zoneInit().
protected void zoneInit()
public final void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
doGet in class javax.servlet.http.HttpServletreq - servlet requestresp - servlet response
public final void doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
doPost in class javax.servlet.http.HttpServletreq - servlet requestresp - servlet response
protected final boolean initMultipartRequest(java.lang.String sTempDir,
int iFileSizeLimit)
mpRequest object. If the file is too big or there is another problem uploading the file then the
method will return false, if everything is ok then it will return true.
sTempDir - temporary folder for the files that are uploadediFileSizeLimit - maximum size of a file
protected int getOnlineUsers()
getApp() for this.
public final java.lang.String getHostName()
public final java.lang.String getHostAddr()
public final java.lang.String getCurrentPage()
DBSession.setLastPage(String)public void log(java.lang.String sMessage)
log in class javax.servlet.GenericServletGenericServlet.log(java.lang.String),
log(int, String)
public void log(int level,
java.lang.String sMessage)
Log for possible logging levels.
level - problem levelsMessage - error message
public void log(int level,
java.lang.String sMessage,
java.lang.Object o)
level - problem levelsMessage - error messageo - object to be logged, special case when the object is a Throwable instancepublic boolean isLoggable(int iLevel)
iLevel - desired logging level
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||