I am trying to run simple application using JSF 2.2, Netbeans 7.3 and GlassFish v2.
index.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">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<b>Hello from Facelets</b>
<h:form id="this">
<h:outputText value="This is"/>
</h:form>
</h:body>
</html>
web.xml
:
<web-app version="2.5" 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-app_2_5.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Output:
The <b>Hello from Facelets</b>
is working but <h:outputText value="this is "/>
is not working. How is this caused and how can I solve it?
I searched here and found the following questions:
However, the answers did not solve myproblem.
Update: @Xtreme Biker, when I changed like you said I got following exception:
Note: If I used *.jsp
instead of *.xhtml
it works. But when I make my index
file extension xhtml
it is not working.
Change your servlet mapping in order to work with .xhtml files. It seems not to be yet converting the tags.
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>