tagged: jsf-setup

Tomcat 7: Setting up JSF 2

Ensure you have the JSF reference implementation. Using gradle this would be:
compile 'com.sun.faces:jsf-api:2.1.19'
compile 'com.sun.faces:jsf-impl:2.1.19'

In your web.xml file you must have:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
	   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
	  <servlet-name>Faces Servlet</servlet-name>
	  <servlet-name>Faces Servlet</servlet-name>

This includes the faces servlet, and sets up a serlvet mapping that intercepts anything that has the faces/ url. Our welcome file will be hello.xhtml.
In our WEB-INF/ folder we now need to define that hello.xhtml file:

Facelets Hello World


Now the differing h namespace that includes all the JSF tags. We'll look at those later.
Now if you go to http://localhost:8080/YOUR_WAR_NAME/faces/index.xhtml you'll see your face. http://localhost:8080/YOUR_WAR_NAME/ will go to the same thanks to the welcome-file-list above.

tomcat tomcat-jsf jsf-setup jsf

Page 1 of 1