1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.portal.portlets;
19
20 import org.apache.ecs.ConcreteElement;
21 import org.apache.ecs.StringElement;
22
23 import org.apache.jetspeed.portal.PortletConfig;
24 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
25 import org.apache.jetspeed.services.logging.JetspeedLogger;
26 import org.apache.jetspeed.portal.portlets.AbstractPortlet;
27 import org.apache.jetspeed.util.servlet.EcsServletElement;
28
29 import org.apache.turbine.util.RunData;
30
31 /***
32 * The ServletInvokerPortlet invokes a servlet or JSP and displays the result.
33 *
34 * @author Thomas Schaeck (schaeck@de.ibm.com)
35 */
36 public class ServletInvokerPortlet extends AbstractPortlet
37 {
38
39 /***
40 * Static initialization of the logger for this class
41 */
42 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(ServletInvokerPortlet.class.getName());
43
44 /***
45 * Returns an ECS concrete element that includes the servlet/JSP.
46 *
47 * The servlet/JSP will be invoked when the ECS tree is written
48 * to the servlet output stream and add its output to the stream.
49 */
50 public ConcreteElement getContent(RunData rundata) {
51
52 PortletConfig pc = this.getPortletConfig();
53
54 String servletURL = null;
55 try {
56 servletURL = (String) this.getPortletConfig().getInitParameter("url");
57 return new EcsServletElement(rundata, servletURL);
58 } catch (Exception e) {
59 String message = "ServletInvokerPortlet: Error invoking "
60 + servletURL + ": " + e.getMessage();
61 logger.error(message, e);
62 return new StringElement(message);
63 }
64 } }