View Javadoc
1 /* 2 * IncludeTag.java 3 * 4 * $Author: mballesteros $ $Date: 2004/01/28 11:56:07 $ $Revision: 1.2 $ 5 */ 6 package net.sf.ewc.taglib; 7 8 import java.io.IOException; 9 import java.util.logging.Level; 10 import java.util.logging.Logger; 11 12 import javax.servlet.ServletException; 13 import javax.servlet.jsp.JspException; 14 15 /*** 16 * {@link IncludeTag}includes another page within. The page to include can be 17 * static or dynamic, depending on whether the <code>page</code> or <code>src</code> 18 * parameter is set. 19 * 20 * @author mballesteros 21 */ 22 public class IncludeTag extends EWCTag { 23 24 /*** 25 * Class logger 26 */ 27 private static Logger logger = Logger.getLogger(IncludeTag.class.getName()); 28 29 private String page; 30 private String src; 31 32 /*** 33 * Sets the expression that evaluates on a String with the page to be 34 * included 35 * 36 * @param src 37 * A valid expression on the current context 38 */ 39 public void setSrc(String src) { 40 this.src = src; 41 } 42 43 /*** 44 * Sets the page to be included. This parameter will not be used if <code>src</code> 45 * is set 46 * 47 * @param page 48 * The page to be included 49 */ 50 public void setPage(String page) { 51 this.page = page; 52 } 53 54 /*** 55 * Main constructor 56 */ 57 public IncludeTag() { 58 super(); 59 } 60 61 /*** 62 * Returns the next processing action, that will be {@link #SKIP_BODY} 63 * 64 * @return The next processing action, that will be {@link #SKIP_BODY} 65 * @throws JspException 66 */ 67 public int doStartTag() throws JspException { 68 String include = (src == null ? page : getExpressionValueAsString(src)); 69 try { 70 pageContext.include(include); 71 } catch (ServletException e) { 72 logger.log(Level.SEVERE, "Error including page: " + include, e); 73 } catch (IOException e) { 74 logger.log(Level.SEVERE, "Error including page: " + include, e); 75 } 76 return SKIP_BODY; 77 } 78 }

This page was automatically generated by Maven