1 16 17 package org.apache.taglibs.xsl; 18 19 20 import java.io.BufferedInputStream ; 21 import java.io.InputStreamReader ; 22 import java.net.URL ; 23 import java.net.URLConnection ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.jsp.JspException ; 26 import javax.servlet.jsp.JspWriter ; 27 import javax.servlet.jsp.PageContext ; 28 import javax.servlet.jsp.tagext.TagSupport ; 29 30 31 38 39 public class ExportTag extends TagSupport { 40 41 42 44 45 48 private String name = null; 49 50 public String getName() { 51 return (this.name); 52 } 53 54 public void setName(String name) { 55 this.name = name; 56 } 57 58 59 62 private String scope = "page"; 63 64 public String getScope() { 65 return (this.scope); 66 } 67 68 public void setScope(String scope) { 69 this.scope = scope; 70 } 71 72 73 75 76 82 public int doStartTag() throws JspException { 83 84 int scopeId = 0; 86 if ("page".equalsIgnoreCase(scope)) 87 scopeId = PageContext.PAGE_SCOPE; 88 else if ("request".equalsIgnoreCase(scope)) 89 scopeId = PageContext.REQUEST_SCOPE; 90 else if ("session".equalsIgnoreCase(scope)) 91 scopeId = PageContext.SESSION_SCOPE; 92 else if ("application".equalsIgnoreCase(scope)) 93 scopeId = PageContext.APPLICATION_SCOPE; 94 else 95 throw new JspException ("Invalid scope value '" + scope + "'"); 96 97 Object bean = pageContext.getAttribute(name, scopeId); 99 if (bean == null) 100 throw new JspException ("Missing JSP bean '" + name + "'"); 101 ; if (!(bean instanceof String )) 103 bean = bean.toString(); 104 105 try { 107 JspWriter out = pageContext.getOut(); 108 out.print((String ) bean); 109 } catch (Exception e) { 110 throw new JspException ("Error writing output: " + e.toString()); 111 } 112 113 return (SKIP_BODY); 115 116 } 117 118 119 } 120 | Popular Tags |