KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > portlet > servlet > WebWorkJSPServlet


1 /*
2  * Copyright (c) 2005 Opensymphony. All Rights Reserved.
3  */

4 package com.opensymphony.webwork.portlet.servlet;
5
6 import com.opensymphony.xwork.ActionContext;
7 import com.opensymphony.xwork.util.OgnlValueStack;
8
9 import javax.servlet.RequestDispatcher JavaDoc;
10 import javax.servlet.ServletException JavaDoc;
11 import javax.servlet.http.HttpServletRequest JavaDoc;
12 import javax.servlet.http.HttpServletResponse JavaDoc;
13 import java.io.IOException JavaDoc;
14
15 /**
16  * When WebWorkPortlet doService() include the JSP resource, then
17  * WebWorkJSPServlet was invoked.
18  * <p/>
19  * Now we can use WebWorkJSPServlet to render the result JSP with the stackValue
20  * stored in ActionContext after WebWork Action was executed.
21  * <p/>
22  * Because PortletRequestDispatcher include() method in WebWorkPortlet
23  * doService() can not filtered by ServletFilter, we must add the SiteMesh
24  * function here if want SiteMesh decoration support.
25  * <p/>
26  *
27  * @author <a HREF="mailto:hu_pengfei@yahoo.com.cn"> Henry Hu </a>
28  * @since 2005-7-6
29  */

30 public class WebWorkJSPServlet extends WebWorkAbstractServlet {
31
32     //~ Constructors
33
// ///////////////////////////////////////////////////////////
34

35     public WebWorkJSPServlet() {
36         super();
37     }
38
39     //~ Methods
40
// ////////////////////////////////////////////////////////////////
41

42     protected void doRequest(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws ServletException JavaDoc, IOException JavaDoc {
43
44         String JavaDoc location = (String JavaDoc) ActionContext.getContext().get("template");
45
46         OgnlValueStack stack = ActionContext.getContext().getValueStack();
47
48 // Moved to Parent class doFilter()
49
// request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,stack);
50
// stack.getContext().put(ServletActionContext.HTTP_REQUEST, request);
51
// stack.getContext().put(ServletActionContext.HTTP_RESPONSE, response);
52
// stack.getContext().put(ServletActionContext.SERVLET_CONTEXT, getServletContext());
53

54         RequestDispatcher JavaDoc dispatcher = request.getRequestDispatcher(location);
55
56         // if the view doesn't exist, let's do a 404
57
if (dispatcher == null) {
58             response.sendError(404, "result '" + location + "' not found");
59             return;
60         }
61
62         dispatcher.include(request, response);
63
64     }
65
66 }
Popular Tags