1 18 19 20 package org.apache.struts.taglib.bean; 21 22 23 import javax.servlet.jsp.JspException ; 24 import javax.servlet.jsp.tagext.TagSupport ; 25 import org.apache.struts.util.MessageResources; 26 import org.apache.struts.taglib.TagUtils; 27 28 29 35 36 public class PageTag extends TagSupport { 37 38 39 41 42 46 protected String id = null; 47 48 public String getId() { 49 return (this.id); 50 } 51 52 public void setId(String id) { 53 this.id = id; 54 } 55 56 57 60 protected static MessageResources messages = 61 MessageResources.getMessageResources 62 ("org.apache.struts.taglib.bean.LocalStrings"); 63 64 65 68 protected String property = null; 69 70 public String getProperty() { 71 return (this.property); 72 } 73 74 public void setProperty(String property) { 75 this.property = property; 76 } 77 78 79 81 82 88 public int doStartTag() throws JspException { 89 90 Object object = null; 92 if ("application".equalsIgnoreCase(property)) 93 object = pageContext.getServletContext(); 94 else if ("config".equalsIgnoreCase(property)) 95 object = pageContext.getServletConfig(); 96 else if ("request".equalsIgnoreCase(property)) 97 object = pageContext.getRequest(); 98 else if ("response".equalsIgnoreCase(property)) 99 object = pageContext.getResponse(); 100 else if ("session".equalsIgnoreCase(property)) 101 object = pageContext.getSession(); 102 else { 103 JspException e = new JspException 104 (messages.getMessage("page.selector", property)); 105 TagUtils.getInstance().saveException(pageContext, e); 106 throw e; 107 } 108 109 pageContext.setAttribute(id, object); 111 return (SKIP_BODY); 112 113 } 114 115 116 119 public void release() { 120 121 super.release(); 122 id = null; 123 property = null; 124 125 } 126 127 128 } 129 | Popular Tags |