|
MDi JLib 1.7.4 |
|||||||||
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
com.microdeveloper.servlets.io.LogServlet
public abstract class LogServlet
A logging class used for tracking events generated by a Servlet.
Logging messages can be embedded in the servlet and activated on demand. The default state is off, but by enabling the logging servlet, these messages can be sent back for debugging purposes.
Override this class and call logMessage() to add messages to the log.Override doGet() to disable the error logging feature for production.
Example:
public class EchoServlet extends LogServlet { public void doPost( PrintWriter out , Hashtable parms ) { String text = parms.getString( "text" ); if ( usable( text ) ) { for ( int i = 0 ; i < 100 ; i++ ) { out.println( text + "<br>" ); } } else { reportProblem( out , "invalid parameters" ); } } }Copyright (c) 2004-2007 MicroDeveloper, Inc.
Field Summary | |
---|---|
protected int |
getCount
increment this if you override the traditional doGet() |
protected int |
postCount
increment this if you override the traditional doPost() |
Constructor Summary | |
---|---|
protected |
LogServlet()
|
Method Summary | |
---|---|
protected void |
checkConsoleLogging()
Call this as the first thing you do if you override the traditional doGet() or doPost(). |
void |
debugReport(PrintWriter out)
Override this if you have more to say in the GET debug information. |
void |
doGet(HttpServletRequest req,
HttpServletResponse resp)
Override this to make the debugger log unavailable. |
protected void |
doGet(PrintWriter out,
Hashtable parameters)
if you need doGet, override this instead of the normal doGet. |
void |
doPost(HttpServletRequest req,
HttpServletResponse resp)
|
protected void |
doPost(PrintWriter out,
Hashtable parameters)
if you need doPost(), override this instead of the normal doPost(). |
void |
emailMessage(PrintWriter out,
String s)
E-mail a message to the admin, send it to the user and add it to the log. |
void |
emailMessage(String s)
E-mail a message to the admin and add the same message to the log. |
void |
init(ServletConfig config)
|
void |
logMessage(String s)
Add a message to the log. |
protected void |
reportProblem(PrintWriter out,
String message)
This convenience method sends the message to the log and sends it to out. |
static void |
setAccessParameterName(String value)
|
static void |
setAccessParameterValue(String value)
|
protected void |
setLogConsole(boolean on)
Messages are sent to STDOUT so they can be tracked in the servlet server logs. |
protected void |
setLogMemory(boolean on)
Messages are logged to memory so they can be viewed by a GET command. |
protected boolean |
usable(String s)
Convenience method - returns true if the string is not null and not empty. |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, 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 |
Field Detail |
---|
protected int postCount
protected int getCount
Constructor Detail |
---|
protected LogServlet()
Method Detail |
---|
public void init(ServletConfig config) throws ServletException
init
in interface Servlet
init
in class GenericServlet
ServletException
public static void setAccessParameterName(String value)
public static void setAccessParameterValue(String value)
protected void setLogMemory(boolean on)
protected void setLogConsole(boolean on)
protected void checkConsoleLogging()
This makes sure that console logging is turned off if it is no longer desired.
public void logMessage(String s)
protected void reportProblem(PrintWriter out, String message)
protected boolean usable(String s)
public void emailMessage(String s)
public void emailMessage(PrintWriter out, String s)
public void debugReport(PrintWriter out)
protected void doPost(PrintWriter out, Hashtable parameters)
out
- use this to send HTML to the browser. parameters
- all of the parameters sent to the servlet are stored in this hash table. public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
doPost
in class HttpServlet
ServletException
IOException
protected void doGet(PrintWriter out, Hashtable parameters)
out
- use this to send HTML to the browser. parameters
- all of the parameters sent to the servlet are stored in this hash table. public void doGet(HttpServletRequest req, HttpServletResponse resp)
doGet
in class HttpServlet
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |