1 16 17 package org.apache.taglibs.io; 18 19 import java.io.IOException ; 20 21 import javax.servlet.ServletContext ; 22 import javax.servlet.jsp.JspException ; 23 import javax.servlet.jsp.tagext.BodyContent ; 24 import javax.servlet.jsp.tagext.BodyTagSupport ; 25 import javax.servlet.jsp.tagext.Tag ; 26 27 32 public abstract class AbstractBodyTag extends BodyTagSupport { 33 34 36 37 protected static final boolean TRACE = false; 38 39 40 protected static final boolean WARN = true; 41 42 43 45 protected void handleException( Exception e ) throws JspException { 46 warn( "ERROR: Caught", e ); 47 if ( e instanceof JspException ) { 48 throw (JspException ) e; 49 } 50 else { 51 pageContext.getServletContext().log( e.getMessage(), e ); 52 53 if ( WARN ) { 54 warn( "Caught Exception: ", e ); 55 } 56 throw new JspException ( e.getMessage() ); 57 } 58 } 59 60 61 protected void warn(String text) { 62 System.out.println( "WARNING: " + text ); 63 } 65 66 protected void warn(String text, Exception e) { 67 System.out.println( "WARNING: " + text + e ); 68 e.printStackTrace(); 70 } 71 72 } 73 | Popular Tags |