URLs are not resolved based on server-side file structure. URLs are resolved based on the actual public web addresses of the respective resources. This is the web browser that has to link to them, and not the web server.
There are several ways to alleviate pain:
JSF EL offers the abbreviated expression ${pageContext.request} in flavor #{request} :
<li><a href="#{request.contextPath}/index.xhtml">Home</a></li> <li><a href="#{request.contextPath}/about_us.xhtml">About us</a></li>
You can use <c:set> if necessary to make it even shorter. Put it somewhere in the main template, it will be available for all pages:
<c:set var="root" value="#{request.contextPath}/" /> ... <li><a href="#{root}index.xhtml">Home</a></li> <li><a href="#{root}about_us.xhtml">About us</a></li>
JSF 2.x offers <h:link> , which can take a view identifier relative to the context root in the outcome , and it will automatically add a context display and FacesServlet :
<li><h:link value="Home" outcome="index" /></li> <li><h:link value="About us" outcome="about_us" /></li>
HTML offers a <base> tag that makes all the relative URLs in the document relative to this base. You can use it. Put it in <h:head> .
<base href="#{request.requestURL.substring(0, request.requestURL.length() - request.requestURI.length())}#{request.contextPath}/" /> ... <li><a href="index.xhtml">Home</a></li> <li><a href="about_us.xhtml">About us</a></li>
(note: this requires EL 2.2, otherwise you better use JSTL fn:substring() , see also this answer )
It should turn out in the generated HTML something like
<base href="http://example.com/webname/" />
Please note that the <base> has a caveat: it does all the anchor bindings on the page, for example, <a href="#top"> with respect to it! See Also. Is it recommended to use the <base> html tag? In JSF, you can solve it as <a href="#{request.requestURI}#top">top</a> or <h:link value="top" fragment="top" /> .