Thursday, April 2, 2009

    Custom Error Pages

    Nope you are wrong, I am not talking about errorPage="true" attribute in this blog. I am talking about few error messages which are sent by the server to the browser like 404. How often you have seen this page.
    Now this is not a good way to treat your site visitors. The main problem with this kind of errors is that than the visitors can drift away from your site. So displaying a custom error message with features like navigation to similar pages or asking them to report a broken link is far better. You can do that pretty easily using the below mentioned solution.

    Implement custom error pages to hide raw exception messages. To do this, simply add something like the following to your web.xml:

    <error-page>
    <error-code>404</error-code>
    <location>/error/404.html</location>
    </error-page>




    Now you are free to write your own custom messages in the 404.html file

    Here is something which is out of scope for this article but you may find interesting. Here are reference to some of the best 404 pages on the web. Best 404 Pages
     

    Site Info

    Text

    Java 2 Enterprise Edition Copyright © 2009 Community is Designed by Bie