1 27 28 29 package com.sun.ebank.web.template; 30 31 import javax.servlet.ServletException ; 32 import javax.servlet.jsp.JspTagException ; 33 import javax.servlet.jsp.PageContext ; 34 import javax.servlet.jsp.tagext.SimpleTagSupport ; 35 import java.util.HashMap ; 36 37 38 public class InsertTag extends SimpleTagSupport { 39 private String parameterName = null; 40 private String definitionName = null; 41 42 public InsertTag() { 43 super(); 44 } 45 46 public void setParameter(String parameter) { 47 this.parameterName = parameter; 48 } 49 50 public void setDefinition(String name) { 51 this.definitionName = name; 52 } 53 54 public void doTag() throws JspTagException { 55 Definition definition = null; 56 Parameter parameter = null; 57 boolean directInclude = false; 58 PageContext context = (PageContext ) getJspContext(); 59 60 definition = 62 (Definition) context.getAttribute(definitionName, 63 context.APPLICATION_SCOPE); 64 65 if ((parameterName != null) && (definition != null)) { 67 parameter = (Parameter) definition.getParam(parameterName); 68 } 69 70 if (parameter != null) { 71 directInclude = parameter.isDirect(); 72 } 73 74 try { 75 if (directInclude && (parameter != null)) { 77 context.getOut() 78 .print(parameter.getValue()); 79 } 80 else { 82 if ((parameter != null) && (parameter.getValue() != null)) { 83 context.include(parameter.getValue()); 84 } 85 } 86 } catch (Exception ex) { 87 Throwable rootCause = null; 88 89 if (ex instanceof ServletException ) { 90 rootCause = ((ServletException ) ex).getRootCause(); 91 } 92 93 throw new JspTagException (ex.getMessage(), rootCause); 94 } 95 } 96 } 97 | Popular Tags |