If you’re a
JSF newbie (like me), and you’re using
Seam, you might be tempted to take one of the examples and hack away at it. For instance, in the booking example, the first page is called
home.xhtml
. After you type up some tags, you want it to run, so you point your browser at:
http://localhost:8080/myapp/home.xhtml
What you’ll find is not a JSF rendered page, but your JSF tag source! Then you think that you’ve misconfigured something, so you look over everything. But what’s really going on is that the Seam example isn’t configured to render that page, instead you should go to:
http://localhost:8080/myapp/home.seam
That will render the home.xhtml as JSF. Look in your war file’s WEB-INF/web.xml
, and find this bit of code:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>
This means that the Faces Servlet logic executes against URLs that end with .seam
. However, being a newbie, I’m not quite sure what maps that against the .xhtml
file, unless it’s this previous entry:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
Also being a newbie, I’m not sure what I should do to configure things so that it’s impossible for a user to download my JSF code…
Anyhow, what makes this all work by default is the file index.html
, which is what will load when you visit:
http://localhost:8080/myapp/
and that contains the following:
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=home.seam">
</head>
</html>
which naturally redirects you to the appropriate URL to start rendering your JSF/Seam application.
Thanks to anyone who points out the answers to the above mysteries (that are probably in the docs somewhere…)