Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse RCP plugin + embedded Jetty + JSF
    primarykey
    data
    text
    <p>I made an RCP plugin with embedded Jetty as following:</p> <p>1) In plugin.xml -> Dependencies, I have added the following:</p> <pre><code>org.eclipse.equinox.http.jetty org.eclipse.equinox.http.registry org.mortbay.jetty.server javax.servlet </code></pre> <p>2) In plugin.xml -> Extensions, I have added a Servlet extension point (<strong>org.eclipse.equinox.http.registry.servlet</strong>)</p> <pre><code>class: TemperatureServlet alias:/temperature </code></pre> <p>The <strong>TemperatureServlet</strong> looks like this:</p> <pre><code>import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class TemperatureServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("doGet Called"); resp.sendRedirect("Convertor.jsp"); } } </code></pre> <p>The file <strong>Convertor.jsp</strong> looks like this:</p> <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%&gt; &lt;%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;f:view&gt; &lt;h:form&gt; &lt;h:panelGrid columns="2"&gt; &lt;h:outputLabel value="Celsius"&gt;&lt;/h:outputLabel&gt; &lt;h:inputText value="#{temperatureConvertor.celsius}"&gt;&lt;/h:inputText&gt; &lt;/h:panelGrid&gt; &lt;h:commandButton action="#{temperatureConvertor.celsiusToFahrenheit}" value="Calculate"&gt;&lt;/h:commandButton&gt; &lt;h:commandButton action="#{temperatureConvertor.reset}" value="Reset"&gt;&lt;/h:commandButton&gt; &lt;h:messages layout="table"&gt;&lt;/h:messages&gt; &lt;/h:form&gt; &lt;h:panelGroup rendered="#{temperatureConvertor.initial!=true}"&gt; &lt;h3&gt; Result &lt;/h3&gt; &lt;h:outputLabel value="Fahrenheit "&gt;&lt;/h:outputLabel&gt; &lt;h:outputLabel value="#{temperatureConvertor.fahrenheit}"&gt;&lt;/h:outputLabel&gt; &lt;/h:panelGroup&gt; &lt;/f:view&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The file faces-config.xml contains:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;temperatureConvertor&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;hellojsf.TemperatureConvertor&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; &lt;/faces-config&gt; </code></pre> <p>My plugin has the following hierarchy:</p> <pre><code>plugin-name ---src ------class package ---------Activator.java ---------Application.java ---------ApplicationActionBarAdvisor.java ---------ApplicationWorkbenchWindowAdvisor.java ---------Perspective.java ---------TemperatureConvertor.java ---------TemperatureServlet.java ---META-INF ------MANIFEST.MF ---resources -------WebContent ----------WEB-INF -------------faces-config.xml -------------web.xml ----------Convertor.jsp ---plugin.xml </code></pre> <p>In <strong>Activator</strong> class, method <strong>start</strong>(), I have started the web server like this:</p> <pre><code>public void start(BundleContext context) throws Exception { super.start(context); plugin = this; Bundle bundle = Platform.getBundle("org.eclipse.equinox.http.registry"); if (bundle.getState() == Bundle.RESOLVED) { bundle.start(Bundle.START_TRANSIENT); } Dictionary settings = new Hashtable(); settings.put("http.enabled", Boolean.TRUE); settings.put("http.port", 8080); settings.put("http.host", "0.0.0.0"); settings.put("https.enabled", Boolean.FALSE); settings.put("context.path", "/"); settings.put("context.sessioninactiveinterval", 1800); try { JettyConfigurator.startServer(PLUGIN_ID + ".jetty", settings); } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>To this plugin I have added also the following libraries:</p> <ul> <li>JSTL: javax.servlet.jsp.jstl-1.2.1-javadoc.jar; javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar </li> <li>JSF 2.0 (Apache MyFaces JSF Core-2.0 API 2.0.2)</li> </ul> <p>After I launch the application, if I type in my browser localhost:8080/temperature</p> <p>It doesn't know where to find Convertor.jsp. My question is: how can I configure this plugin to know the resource location WebContent and the most important, how can I configure the plugin to know how to process JSFs and to know about the faces-config.xml and web.xml.</p> <p>Can I, for example, when I define the extension org.eclipse.equinox.http.registry.servlets, do something like this? class: javax.faces.webapp.FacesServlet alis: /*.jsp</p> <p>(all the files *.jsp to be processed by the FacesServlet)?</p> <p>Thank you very much and sorry if the questions are silly, but I am new in this area of RCP plugins, Jetty and JSF.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload