Working with JSPs in JSF 2.0

Java server faces

Working with JSPs in JSF 2.0

By Jason Tee

TheServerSide.com

If you’ve been working with JavaServer Faces in the past, you’re probably used to working with JSPs as your view technology. Of course, with JSF 2.0, the new push is for developers to use Facelets as their templating technology, and rightly so, as Facelets provide a much more flexible and adaptable mechanism for developing user interfaces.

Of course, with JSF 2.0, the container is going to be looking for xhtml files by default, which isn’t good if you’re still working with JavaServer Pages. But don’t fret, as there’s an easy fix. All you have to do is edit your web.xml file and tell the container that your default view technology should be JSPs.

 

 <context-param>     <param-name>javax.faces.DEFAULT_SUFFIX</param-name>     <param-value>.jsp</param-value> </context-param>

 

With that small change, the JSF 2.0 framework will start pulling up JSP files instead of xhtml files, just like it did by default in the previous version.

27 Dec 2010

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.