FacesServlet is not interpreting my xhtml code

16 Views Asked by At

I have the JSF set-up listed below. If I call

http://localhost:8080/newSheet.jsf

I do get the original xhtml page contents instead of the rendered html output.

I know this has been asked many times on SO. The answer seams that the web.xml set-up is not correct causing the FacesServlet to not be invoked.

However my case is different. I have a break point on FacesServlet.service() which is hit every time. I also checked, that it is called with the desired URL.

web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id="WebApp_ID" version="2.5">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <!--
     FacesServlet is main servlet responsible to handle all request.
     It acts as central controller.
     This servlet initializes the JSF components before the JSP is displayed.
  -->
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
</web-app>

newSheet.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<h:body>
    <h:form>
        <h1>
            <h:outputText>Add a new sheet</h:outputText>
        </h1>
        <p>
            <h:outputText>Description</h:outputText>
            <h:inputText value="{#addSheet.description}" />
        </p>
        <p>
            <h:outputText>Widht</h:outputText>
            <h:inputText value="{#addSheet.width}" />
        </p>
        <p>
            <h:outputText>Height</h:outputText>
            <h:inputText value="#{addSheet.height}" />
        </p>
        <h:commandButton value="Submit" action="#{addSheet}"/>
    </h:form>
</h:body>
</html>
0

There are 0 best solutions below