com.ora.jsp.tags.xmp
Class ClassicFileWriteTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended bycom.ora.jsp.tags.xmp.ClassicFileWriteTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally

public class ClassicFileWriteTag
extends javax.servlet.jsp.tagext.BodyTagSupport
implements javax.servlet.jsp.tagext.TryCatchFinally

This class is a custom action for writing the content of the action element's body to a file specified by an attribute, or to System.out if no file is specified. If the file name "log" is specified, the standard application log file is used.

Version:
1.0
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  java.lang.String fileName
           
private  java.io.PrintWriter pw
           
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
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
ClassicFileWriteTag()
           
 
Method Summary
 int doAfterBody()
          Writes the content accumulated in bodyContent to the file.
 void doCatch(java.lang.Throwable t)
          Log the problem and rethrow the exception.
 void doFinally()
          Closes the file, no matter if an exception was thrown by the body evaluation or not.
 int doStartTag()
          Makes sure the specified file can be opened for writing.
 void setFileName(java.lang.String fileName)
           
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doEndTag, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

fileName

private java.lang.String fileName

pw

private java.io.PrintWriter pw
Constructor Detail

ClassicFileWriteTag

public ClassicFileWriteTag()
Method Detail

setFileName

public void setFileName(java.lang.String fileName)

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Makes sure the specified file can be opened for writing. If so, tells the container to evaluate the body.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Throws:
javax.servlet.jsp.JspException

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Writes the content accumulated in bodyContent to the file.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Throws:
javax.servlet.jsp.JspException

doCatch

public void doCatch(java.lang.Throwable t)
             throws java.lang.Throwable
Log the problem and rethrow the exception.

Specified by:
doCatch in interface javax.servlet.jsp.tagext.TryCatchFinally
Throws:
java.lang.Throwable

doFinally

public void doFinally()
Closes the file, no matter if an exception was thrown by the body evaluation or not. Note that this method is called even if an exception is thrown by doStartTag(), or any other doXXX() method. In this case, the file may not have been opened at all.

Specified by:
doFinally in interface javax.servlet.jsp.tagext.TryCatchFinally