This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am trying to customize 404 error page for Tomcat server. Sometimes, this is very important because you may need to redirect the specific request to special error page. Sure, you can add the 404 error page in your web.xml, however, this is not customized page because it doesn't know what is the original request. I know, you can customize a 404 error page for Apache server by knowing what are the original requests, like it was mentioned in: Custom Error Pages with PHP and Apache. My question is that if you cann't configure your Apache server but Tomcat, what I can do to customize the 404 error pages? Thanks [ August 06, 2003: Message edited by: William Chang ]
you can add the 404 error page in your web.xml, however, this is not customized page because it doesn't know what is the original request.
Sure it does. Since the error page is forwarded to from the request that causes the error, the request environment is still available. In fact, a number of request attributes are added to the request to help you create helpful customized error messages. bear
By the way, the relevant section of the JavaServlet 2.3 Specification is SRV.9.9. And here's some not-so-subtle advice: if you are working with Tomcat or any other servlet engine and haven't read the Servlet Specification, you're doing it wrong! Seriously, the spec may seem daunting but it's actually very well written, especially for a technical specification, and is an easy read. Do yourself a favor and get a copy from Sun's web site. Keep the PDF handy, or even make a hard-copy for your desk. hth, bear [ August 06, 2003: Message edited by: Bear Bibeault ]
Joined: Aug 06, 2003
I wish that you have tried it by youself. Thanks.
Joined: Aug 06, 2003
I think that I have not made myself clear. In your web.xml, you add: <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page> Whenever there is 404 error, e.g., the user type XXX.com/wrong_url, the tomcat will lead to /error.jsp. The error.jsp won't know where the 404 error comes from, I mean, because the user typed wrong_url. If you know, please let me know. Thanks. [ August 09, 2003: Message edited by: William Chang ] [ August 09, 2003: Message edited by: William Chang ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How to customize the 404 error page for Tomcat