I'm trying as simply as possible to deal with error handling in a "forked" JSF2 application, which has separate templates and XHTML page paths for mobile and desktop.
The main servlet mapping (maybe in need of modification) currently looks like this
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>/javax.faces.resource/*</url-pattern>
</servlet-mapping>
In my situation, this works fine for handling desktop errors:
<error-page>
<error-code>404</error-code>
<location>/faces/webpages/filenotfound.xhtml</location>
</error-page>
<error-page>
<exception-type>java.io.FileNotFoundException</exception-type>
<location>/faces/webpages/filenotfound.xhtml</location>
</error-page>
But given the forked sets of pages and templates, I would also like to have
<error-page>
<error-code>404</error-code>
<location>/faces/mpages/filenotfound.xhtml</location>
</error-page>
<error-page>
<exception-type>java.io.FileNotFoundException</exception-type>
<location>/faces/mpages/filenotfound.xhtml</location>
</error-page>
Is there a way to do this directly in the web.xml
, either using paths that aren't relative to the context root or by nesting some of the config in blocks that define the path to use in different scenarios? Or to use faces-config.xml
and create custom outcomes that can be matched to exact XHTML file locations?