1 16 17 package org.apache.taglibs.io; 18 19 import java.io.BufferedReader ; 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.io.InputStreamReader ; 23 import java.io.OutputStream ; 24 import java.io.OutputStreamWriter ; 25 import java.io.Reader ; 26 import java.io.Writer ; 27 import java.net.HttpURLConnection ; 28 import java.net.URL ; 29 import java.net.URLConnection ; 30 31 import javax.servlet.ServletContext ; 32 import javax.servlet.jsp.JspException ; 33 import javax.servlet.jsp.JspWriter ; 34 import javax.servlet.jsp.tagext.BodyContent ; 35 import javax.servlet.jsp.tagext.TagSupport ; 36 37 42 public class AbstractTag extends TagSupport { 43 44 46 47 protected static final boolean TRACE = false; 48 49 50 protected static final boolean WARN = true; 51 52 53 public AbstractTag() { 54 } 55 56 58 protected void handleException( Exception e ) throws JspException { 59 warn( "ERROR: Caught", e ); 60 if ( e instanceof JspException ) { 61 throw (JspException ) e; 62 } 63 else { 64 pageContext.getServletContext().log( e.getMessage(), e ); 65 66 if ( WARN ) { 67 warn( "Caught Exception: ", e ); 68 } 69 throw new JspException ( e.getMessage() ); 70 } 71 } 72 73 protected void warn(String text) { 74 System.out.println( "WARNING: " + text ); 75 } 77 78 protected void warn(String text, Exception e) { 79 System.out.println( "WARNING: " + text + e ); 80 e.printStackTrace(); 82 } 83 84 protected void log(String text ) { 85 System.out.println( text ); 86 } 88 89 } 90 | Popular Tags |