com.taggercat.tags
Class ExceptionTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by com.taggercat.tags.AbstractExpEvalTag
          extended by com.taggercat.tags.ExceptionTag
All Implemented Interfaces:
com.taggercat.el.ELPropertyResolver, java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class ExceptionTag
extends AbstractExpEvalTag

This tag returns the current exception message, and optionally the associated stack trace.

If there is no exception on the page, then the tag has no output.

If the exception has no message, then the message defaults to: "No Exception message is available."

Exception Tag Attribute Summary
Name Required Request-time Default Type Description
label false true null String The label to prefix the exception message.
lineSeparator false true null String The characters to use for line breaks. This is useful if creating a JavaScript variable.
stackTrace false true false boolean Set true to include the stack trace. This can be an expression.
escapeHTML false true false boolean Set true to escape HTML in the message, for example <, >, "
escapeQuotes false true false Boolean Set true to escape double quotes " with a preceding slash \". This is useful if creating a JavaScript variable.
preformat false true true Boolean Set true to wrap the message and the stack trace in <pre> and </pre> tags.

Typical usage:


 <tc:exception label='An error has occured..' escapeHTML='true' stackTrace='true' preformat='true' />

To include the exception in a JavaScript alert() method, you can use code such as:


 <script language="JavaScript" >
 function showErrors()
 {
   var errorMessage = "<tc:exception preformat='false' lineSeparator='\\n' escapeQuotes='true' />";
   if( errorMessage != "" ) { alert( errorMessage ); }
 }
 </script>
And then in page's HTML body tag, call the showErrors() function using code such as:
 <body onLoad="enableControls(), showErrors()" >

See Also:
Serialized Form
 

Field Summary
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
ExceptionTag()
          Creates a new Exception tag.
 
Method Summary
 int doEndTag()
          Resets the tags internal state.
 int doStartTag()
          Sends the value of the data field to the page.
 void setEscapeHTML(boolean escapeHTML)
          Sets the property to escape any HTML characters in the exception message with the appropriate HTML escape sequence.
 void setEscapeQuotes(boolean escapeQuotes)
          Sets the property to escape any double quotes in the exception message with a preceding back slash \ character.
 void setLabel(java.lang.String label)
          Sets the label to print before the exception message.
 void setLineSeparator(java.lang.String lineSeparator)
          Sets the lineSeparator to use between lines of the exception message.
 void setpreformat(boolean preformat)
          Sets the property to preformat the stacktrace using <PRE> and </PRE> tags.
 void setStackTrace(boolean stackTrace)
          Set the property to include the stack trace with the exception.
 void setStackTrace(java.lang.String stackTrace)
          Set the property to include the stack trace with the exception.
 
Methods inherited from class com.taggercat.tags.AbstractExpEvalTag
getModel, resolveProperty, setScope, setValue, setVar
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionTag

public ExceptionTag()
Creates a new Exception tag.

Method Detail

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Resets the tags internal state.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class AbstractExpEvalTag
Throws:
javax.servlet.jsp.JspException
Returns:
EVAL_PAGE

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Sends the value of the data field to the page.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class AbstractExpEvalTag
Throws:
javax.servlet.jsp.JspException
Returns:
SKIP_BODY

setLineSeparator

public void setLineSeparator(java.lang.String lineSeparator)
Sets the lineSeparator to use between lines of the exception message. The default lineSeparator is a new line character.

If you are including the exception in a JavaScript alert() function, then use the lineSeparator='\\n'.

Parameters:
lineSeparator - the lineSeparator

setStackTrace

public void setStackTrace(java.lang.String stackTrace)
Set the property to include the stack trace with the exception.

Parameters:
stackTrace - set true to include the stacktrace

setStackTrace

public void setStackTrace(boolean stackTrace)
Set the property to include the stack trace with the exception.

Parameters:
stackTrace - set true to include the stacktrace

setEscapeQuotes

public void setEscapeQuotes(boolean escapeQuotes)
Sets the property to escape any double quotes in the exception message with a preceding back slash \ character. Set this to true if creating a JavaScript String variable with the message.

Parameters:
escapeQuotes - set true to escape double quotes

setEscapeHTML

public void setEscapeHTML(boolean escapeHTML)
Sets the property to escape any HTML characters in the exception message with the appropriate HTML escape sequence. Set this to true if printing the message directly to the page.

Parameters:
escapeHTML - set true to escape double quotes
See Also:
Text.escapeHTML(String text)

setLabel

public void setLabel(java.lang.String label)
Sets the label to print before the exception message.

Parameters:
label - the label

setpreformat

public void setpreformat(boolean preformat)
Sets the property to preformat the stacktrace using <PRE> and </PRE> tags. The default is true.

Parameters:
preformat - set true to preformat the message and stack trace