Skip to main content

Running JSF 2.0 w/Both JSP and Facelet View Technologies

1 reply [Last post]
onlizer
Offline
Joined: 2010-05-03
Points: 0

According to the "Dive into JSF" article with Ed Burns - http://www.jsfcentral.com/articles/burns-05-09.html - JSF 2.0 supports running both JSP and Facelet view technologies. Ed makes the statement "What the strategy we envision is, people will take their existing JSF app that might use JSP, probably uses JSP, and then they run it in the JSF 2.0 runtime and then they make a page by page migration."

What I'm wondering is how I configure faces to allow both JSP and Facelet pages to map/display correctly in order to make such a migration.

Thanks!

Joe

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
edburns
Offline
Joined: 2004-02-11
Points: 0

This should "just work". Here's a simple example with implicit navigation. The only gotcha is that when you are mixing JSP and Facelets with implicit navigation, I've found that you must include the file extension in the implicit navigation.

./web/WEB-INF/web.xml


javax.faces.PROJECT_STAGE Development

Faces Servlet
javax.faces.webapp.FacesServlet
1


Faces Servlet
/faces/*


Faces Servlet
*.jsf



30



faces/index.xhtml


./web/index.xhtml


xmlns:h="http://java.sun.com/jsf/html">

JSP and Facelets in One Project


Implicit navigation from Facelets to JSP and back.




./web/toFacelets.xhtml


xmlns:h="http://java.sun.com/jsf/html">

Facelet Title




./web/toJsp.jsp
<%--
Document : toJsp
Created on : Jun 30, 2010, 10:46:08 PM
Author : edburns
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
"http://www.w3.org/TR/html4/loose.dtd">




JSP Page