4

I develop a web application on Apache Tomcat (Version 7) using JSF2. End users will probably fidget around with the address bar of a web application. I want to impose a default behavior on cases when users either call for a subpage that does not exist (which normally leads to a Tomcat file-not-found page ("The requested resource () is not available.") or call the application without specifying a startpage (like http://localhost:8080/App/). My desired behavior would be to redirect the user to a custom page with more telling information than a default server error message.

I have not figured out an available link between my JSF application and Tomcat. I tried to solve this problem using a Phase Listener, but it does not work - as no page associated with my application is requested. How to achieve this in the aforementioned technological environment?

Simon Voggeneder
  • 377
  • 1
  • 7
  • 16
  • did any of our answers solve your problem? if so, please be so kind and mark the correct answer! ;) –  Jun 21 '11 at 11:38
  • 1
    @donneo: according to the OP's question history he already know how things works here. – BalusC Jun 21 '11 at 12:51
  • Confirmed, I do :) Still I'm not permanently logged in to SO, so there will be some time lag between posing a question and handling the incoming answers. – Simon Voggeneder Jun 21 '11 at 13:58

2 Answers2

4

You can specify your own errorpages in the deployment descriptor (web.xml):

Errorpages in web.xml

You can even define Exception-specific error pages, i.e. if you want to display an error-page for the infamous ViewExpiredException.

I hope this helps!

3

You can define the location of a custom HTTP 404 error page in web.xml.

<error-page>
    <error-code>404</error-code>
    <location>/errorpages/404.html</location>
</error-page>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555