I’ve got a tiny webapp with index.jsp that forwards (it mostly only contains):
<jsp:forward page="/pages/inputname.jsf" />
web.xml contains (in addition to everything else you’d expect; see more below):
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
inputname.jsp isn’t rendering (here’s the URI):
http://localhost:8080/simpleWeb/index.jsp
The page appears thus in the browser (label, input edit field, button):
#{msg.prompt} #{personBean.personName} #{msg.button_text}
I’m guessing this is because it’s not getting through the Faces servlet. However, I’m uncertain of how to force it through. (Note that I’m elsewhere, with RichFaces and MyFaces, having similar trouble with .xhtml files too, but I’d like to get this simpler case solved first.)
The tutorial has me using these libraries (via Maven), in WEB-INF/lib/:
avalon-framework-4.1.3.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-logging-1.1.jar
jsf-api-1.2_02.jar
jsf-impl-1.2-b19.jar
jstl-1.1.2.jar
log4j-1.2.12.jar
logkit-1.0.1.jar
servlet-api-2.3.jar
standard-1.1.2.jar
Any help would be greatly appreciated.
web.xml (yes, it has the DOCTYPE web-app header):
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<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>
Two solutions:
index.jspneeds to be called asindex.jsfby browser.index.jspshould fire a redirect rather than forward. JSTL<c:redirect>may be useful.Regardless, such an
index.jspis pretty pointless. Just add/pages/inputname.jsfas<welcome-file>inweb.xmland provide a blank/pages/inputname.jsffile next to the real/pages/inputname.jspto fool the server that the file exist (otherwise it will go 404).As to the
web.xml, theDOCTYPEdoesn’t belong there. It’s an ancient remnant of Servlet 2.3 approach and before (almost a decade old already). On Servlet 2.4 and newer, there are XSD’s. Even more, since you’re using JSF 1.2, theweb.xmlshould be declared as at least Servlet 2.4, preferably higher, the highest your container can support, so that you can utilize the newest available API facilities. Tomcat 5.5 is Servlet 2.4, Tomcat 6.0 is Servlet 2.5 and Tomcat 7.0 is Servlet 3.0.See also: