KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > SetTag


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp;
6
7 import com.opensymphony.xwork.util.OgnlValueStack;
8
9 import javax.servlet.jsp.JspException JavaDoc;
10
11
12 /**
13  * @author $Author: plightbo $
14  * @version $Revision: 1.8 $
15  */

16 public class SetTag extends WebWorkTagSupport {
17     //~ Instance fields ////////////////////////////////////////////////////////
18

19     String JavaDoc name;
20     String JavaDoc scope;
21     String JavaDoc value;
22
23     //~ Methods ////////////////////////////////////////////////////////////////
24

25     public void setName(String JavaDoc name) {
26         this.name = name;
27     }
28
29     public void setScope(String JavaDoc scope) {
30         this.scope = scope;
31     }
32
33     public void setValue(String JavaDoc value) {
34         this.value = value;
35     }
36
37     public int doStartTag() throws JspException JavaDoc {
38         OgnlValueStack stack = getStack();
39
40         if (value == null) {
41             value = "top";
42         }
43
44         Object JavaDoc 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