com.ora.jsp.util
Class DebugBean

java.lang.Object
  |
  +--com.ora.jsp.util.DebugBean

public class DebugBean
extends java.lang.Object

This class is a bean that can be used to extract debug information from a JSP PageContext. The debug info is sent to the browser, System.out, and the servlet log file, depending on the value of the "debug" request parameter sent with the request for the JSP page: "resp", "stdout" and "log". The values can be combined to get the information directed to multiple targets.

Version:
1.0
Author:
Hans Bergsten, Gefion software

Field Summary
private  javax.servlet.ServletContext context
           
private  java.lang.String debugType
           
private static java.lang.String LINE_FEED
           
private  javax.servlet.jsp.PageContext pageContext
           
private  long startTime
           
 
Constructor Summary
DebugBean()
          Creates an instance and initializes the timer.
 
Method Summary
 java.lang.String getApplicationScope()
          Returns a String with all application scope variables.
 java.lang.String getCookies()
          Returns a String with all cookie information.
 java.lang.String getElapsedTime()
          Returns a String with the number of milliseconds that has passed since the bean was created or the last time this method was called.
 java.lang.String getHeaders()
          Returns a String with all header information.
 java.lang.String getPageScope()
          Returns a String with all page scope variables.
 java.lang.String getParameters()
          Returns a String with all request parameter information.
 java.lang.String getRequestInfo()
          Returns a String with all basic request information.
 java.lang.String getRequestScope()
          Returns a String with all request scope variables.
 java.lang.String getSessionScope()
          Returns a String with all session scope variables.
private  java.lang.String handleMsg(java.lang.String propName, java.util.Hashtable values)
          If debug is activated, writes the specified property value to the log file and returns it as an HTML table, depending on the requested debug type.
private  java.lang.String handleMsg(java.lang.String propName, java.lang.String msg)
          Returns a String suitable for browser debug display and sends the debug message to System.out and/or the servlet log file, depending on the value of the "debug" request parameter.
private  boolean isDebugActive()
          Returns true if the pageContext attribute has been set and a valid "debug" request parameter is present in the request.
private  void log(java.lang.String propName, java.util.Hashtable values)
           
private  void log(java.lang.String propName, java.lang.String msg)
          Writes the specified property value to the System.out or the log file, depending on the requested debug type.
private  java.lang.String nullToString(java.lang.String value)
          Returns the String "null" if the value is null, otherwise the value itself.
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Sets the pageContext property.
private  java.lang.String toHTMLTable(java.lang.String propName, java.util.Hashtable values)
          Returns an HTML table with all the values of the specified property.
private  java.lang.String toStringValue(java.lang.Object value)
          Returns a String representation of the specified Object, in a format suitable for debug output.
private  java.lang.String toTabbedTable(java.util.Hashtable values)
          Returns an simple ASCII table with all the values of the specified property, used for log output.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

LINE_FEED

private static final java.lang.String LINE_FEED

pageContext

private javax.servlet.jsp.PageContext pageContext

startTime

private long startTime

debugType

private java.lang.String debugType

context

private javax.servlet.ServletContext context
Constructor Detail

DebugBean

public DebugBean()
Creates an instance and initializes the timer.
Method Detail

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Sets the pageContext property.

getElapsedTime

public java.lang.String getElapsedTime()
Returns a String with the number of milliseconds that has passed since the bean was created or the last time this method was called.

getRequestInfo

public java.lang.String getRequestInfo()
Returns a String with all basic request information.

getHeaders

public java.lang.String getHeaders()
Returns a String with all header information.

getCookies

public java.lang.String getCookies()
Returns a String with all cookie information.

getParameters

public java.lang.String getParameters()
Returns a String with all request parameter information.

getRequestScope

public java.lang.String getRequestScope()
Returns a String with all request scope variables.

getPageScope

public java.lang.String getPageScope()
Returns a String with all page scope variables.

getSessionScope

public java.lang.String getSessionScope()
Returns a String with all session scope variables.

getApplicationScope

public java.lang.String getApplicationScope()
Returns a String with all application scope variables.

nullToString

private java.lang.String nullToString(java.lang.String value)
Returns the String "null" if the value is null, otherwise the value itself.

isDebugActive

private boolean isDebugActive()
Returns true if the pageContext attribute has been set and a valid "debug" request parameter is present in the request.

handleMsg

private java.lang.String handleMsg(java.lang.String propName,
                                   java.lang.String msg)
Returns a String suitable for browser debug display and sends the debug message to System.out and/or the servlet log file, depending on the value of the "debug" request parameter. If debug is not active, an empty String is returned.

handleMsg

private java.lang.String handleMsg(java.lang.String propName,
                                   java.util.Hashtable values)
If debug is activated, writes the specified property value to the log file and returns it as an HTML table, depending on the requested debug type.

log

private void log(java.lang.String propName,
                 java.lang.String msg)
Writes the specified property value to the System.out or the log file, depending on the requested debug type.

log

private void log(java.lang.String propName,
                 java.util.Hashtable values)

toHTMLTable

private java.lang.String toHTMLTable(java.lang.String propName,
                                     java.util.Hashtable values)
Returns an HTML table with all the values of the specified property.

toTabbedTable

private java.lang.String toTabbedTable(java.util.Hashtable values)
Returns an simple ASCII table with all the values of the specified property, used for log output.

toStringValue

private java.lang.String toStringValue(java.lang.Object value)
Returns a String representation of the specified Object, in a format suitable for debug output.