KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > ServletActionContext


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

5 package com.opensymphony.webwork;
6
7 import com.opensymphony.xwork.ActionContext;
8
9 import javax.servlet.ServletContext JavaDoc;
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11 import javax.servlet.http.HttpServletResponse JavaDoc;
12 import javax.servlet.jsp.PageContext JavaDoc;
13 import java.util.Map JavaDoc;
14
15
16 /**
17  * Web-specific context information for actions. This class subclasses <tt>ActionContext</tt> which
18  * provides access to things like the action name, value stack, etc. This class adds access to
19  * web objects like servlet parameters, request attributes and things like the HTTP session.
20  *
21  * @author <a HREF="mailto:nightfal@etherlands.net">Erik Beeson</a>
22  * @author Bill Lynch (docs)
23  */

24 public class ServletActionContext extends ActionContext implements WebWorkStatics {
25     public static final String JavaDoc WEBWORK_VALUESTACK_KEY = "webwork.valueStack";
26     //~ Constructors ///////////////////////////////////////////////////////////
27

28     private ServletActionContext(Map JavaDoc context) {
29         super(context);
30     }
31
32     //~ Methods ////////////////////////////////////////////////////////////////
33

34     /**
35      * Returns the HTTP page context.
36      *
37      * @return the HTTP page context.
38      */

39     public static PageContext JavaDoc getPageContext() {
40         return (PageContext JavaDoc) ActionContext.getContext().get(PAGE_CONTEXT);
41     }
42
43     /**
44      * Sets the HTTP servlet request object.
45      *
46      * @param request the HTTP servlet request object.
47      */

48     public static void setRequest(HttpServletRequest JavaDoc request) {
49         ActionContext.getContext().put(HTTP_REQUEST, request);
50     }
51
52     /**
53      * Gets the HTTP servlet request object.
54      *
55      * @return the HTTP servlet request object.
56      */

57     public static HttpServletRequest JavaDoc getRequest() {
58         return (HttpServletRequest JavaDoc) ActionContext.getContext().get(HTTP_REQUEST);
59     }
60
61     /**
62      * Sets the HTTP servlet response object.
63      *
64      * @param response the HTTP servlet response object.
65      */

66     public static void setResponse(HttpServletResponse JavaDoc response) {
67         ActionContext.getContext().put(HTTP_RESPONSE, response);
68     }
69
70     /**
71      * Gets the HTTP servlet response object.
72      *
73      * @return the HTTP servlet response object.
74      */

75     public static HttpServletResponse JavaDoc getResponse() {
76         return (HttpServletResponse JavaDoc) ActionContext.getContext().get(HTTP_RESPONSE);
77     }
78
79     /**
80      * Gets the servlet context.
81      *
82      * @return the servlet context.
83      */

84     public static ServletContext JavaDoc getServletContext() {
85         return (ServletContext JavaDoc) ActionContext.getContext().get(SERVLET_CONTEXT);
86     }
87
88     public static void setServletContext(ServletContext JavaDoc servletContext) {
89         ActionContext.getContext().put(SERVLET_CONTEXT, servletContext);
90     }
91 }
92
Popular Tags