This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I have a jsp page which has a jsp:include to include a html page. When the html page is not present I get a 404 Page not found error. Is there a way where I can display my own error page instead of the 404 - Page not found page?
The servlet spec provides a mechanism that allows you to assign your own pages by error type. There is a link in my signature. Search for "error-page" and you will find the section quickly.
As for included pages. I wouldn't consider it a normal issue to have pages with broken include directives and I'm not sure how the error-page mechanism handles this. You'll have to play around with it and see.
What other suggestions do you need besides what Ben already said. Having a jsp with includes that reference missing files is an error. The container displays your configured error page when it occurs. bottom line is to avoid the error. So do not try to include or forward to resources that do not exist.
Originally posted by Sudarshan Chakrabarty: Configuring the web.xml to add the following entry seems to help.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Joined: Apr 10, 2008
Thanks for your insight. I appreciate your concern, but unfortunately the application is such that sometimes the included file might not be present and so we need to show our custom error page. Not the best of designs I am afraid but that's how the application has been designed long back :-(.
I will definitely try to push for a redesign, but till then I needed a solution :-(.. Thanks again. - Sudarshan
Joined: Apr 10, 2008
Oh forgot to mention...
Adding the following web.xml entry doesn't seem to help :-(.
Apparently,if the page is missing when we do a jsp:include, then it doesn't get registered as an error or exception, so it is not being identified as a 404 error. Hence, the error.jsp is not displayed :-(.