I want to create JSF 2.0 project in Eclipse 3.6 and I want to deploy it on Websphere Application Server Community Edition 2.1.
I created a simple web project.
And in index.html I write this code
<!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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>JSF 2.0</title>
</h:head>
<h:body>
jsf welcome
</h:body>
</html>
But the text between <h:body> and <h:body> tags can not be seen in the page. How can I solve this problem?
This is buildpath:

And this is the web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<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">
<display-name>JSFApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
Is there any mistake ?
There are 2 problems:
You're using
.htmlinstead of.xhtml. JSF 2.0 by default resolves views on*.xhtml. Rename yourindex.htmltoindex.xhtml.You should open the page in browser by an URL matching the
url-patternof theFacesServlet, which is/faces/*in your case. Thus so: http://example.com/contextname/faces/index.xhtml and not so http://example.com/contextname/index.xhtml and even not .html.However, I'd recommend to replace
/faces/*by*.xhtmlso that you (and your endusers) don't need to be surprised when omitting or forgetting the/facespart in the URL. The only disadvantage is that you won't be able to serve "plain vanilla".xhtmlfiles without involvement ofFacesServlet, but this is almost never the case in real world. Rather just serve such files as.htmlthen.See also: