1 5 package com.opensymphony.webwork.views.jsp; 6 7 import com.opensymphony.xwork.util.OgnlValueStack; 8 9 import javax.servlet.jsp.JspException ; 10 11 12 16 public class SetTag extends WebWorkTagSupport { 17 19 String name; 20 String scope; 21 String value; 22 23 25 public void setName(String name) { 26 this.name = name; 27 } 28 29 public void setScope(String scope) { 30 this.scope = scope; 31 } 32 33 public void setValue(String value) { 34 this.value = value; 35 } 36 37 public int doStartTag() throws JspException { 38 OgnlValueStack stack = getStack(); 39 40 if (value == null) { 41 value = "top"; 42 } 43 44 Object o = findValue(value); 45 46 if ("application".equals(scope)) { 47 super.pageContext.getServletContext().setAttribute(name, o); 48 } else if ("session".equals(scope)) { 49 pageContext.getSession().setAttribute(name, o); 50 } else if ("request".equals(scope)) { 51 pageContext.getRequest().setAttribute(name, o); 52 } else if ("page".equals(scope)) { 53 pageContext.setAttribute(name, o); 54 } else { 55 stack.getContext().put(name, o); 56 } 57 58 return SKIP_BODY; 59 } 60 } 61 | Popular Tags |