I found this Mixing JSP and XHTML (Facelets) in JSF2 Project – possible? when I searched for a way to use .jsp and .xhtml together.
That question is answered with a link to a FAQ that states that I must use prefix mapping but I can’t figure out how. I understand that I must add facelets.VIEW_MAPPINGS but that wording on “You have to use prefix mapping” is what I cant understand.
Basically i’m supposed to acess my page with /faces/ included like: “http://localhost:8080/webapp/faces/mypage.xhtml“
But if I try to add /faces/ manually it goes 404. And I’m not sure if it should be added automatically when running the app or not.
My welcome file is a html page that uses: <body bgcolor="#FFFFFF" onload="window.location='/portal/login/login.xhtml'">
should it really be .xhtml and not .jsf?
Prior to trying to blend with the JSP pages and only trying out JSF2 I ran it like this succesfully:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</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>
Using /faces/* instead seems to be a must but I just don’t understand how to use it properly.
I’m trying it like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<!-- Use extensions mapping for Faces servlet -->
<context-param>
<param-name>facelets.VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</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>
This regards a big application built with pure jsp pages and jsp pages with JSF 1.2. Basically i’m converting all the jsf pages into jsf2 and thus xhtml.
While above suggestion actually did work I didnt want to change the urls everywere and I got the preface mapping to work by using the correct parameter.
does not work:
works: