01: package test;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05:
06: import javax.servlet.ServletException;
07:
08: import javax.portlet.GenericPortlet;
09: import javax.portlet.PortletException;
10: import javax.portlet.RenderRequest;
11: import javax.portlet.ActionResponse;
12: import javax.portlet.RenderResponse;
13: import javax.portlet.PortletContext;
14: import javax.portlet.PortletRequestDispatcher;
15: import javax.portlet.PortletConfig;
16:
17: public class NamedDispatcherGetAttributePortlet extends GenericPortlet {
18:
19: static private String INCLUDED_SERVLET = "GetIncludedServlet";
20: private PortletContext pContext;
21:
22: public void init(PortletConfig config) throws PortletException {
23:
24: super .init(config);
25: pContext = config.getPortletContext();
26: }
27:
28: public void doView(RenderRequest request, RenderResponse response)
29: throws PortletException {
30:
31: response.setContentType(request.getResponseContentType());
32: try {
33: PrintWriter writer = response.getWriter();
34: writer
35: .write("Test for getting javax.servlet.* attributes:<p><p>");
36: PortletRequestDispatcher dispatcher = pContext
37: .getNamedDispatcher(INCLUDED_SERVLET);
38: dispatcher.include(request, response);
39: } catch (IOException ie) {
40: throw new PortletException(
41: "NamedDispatcherGetAttributePortlet.doView exception",
42: ie);
43: }
44:
45: }
46: }
|