Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble with Error Pages

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I can't configure the error pages. I have created my own RunTimeException and configured the DD as shown here:

<error-page>
<exception-type>com.myserver.DateNotFoundException</exception-type>
<location>/error.jsp</location>
</error-page>


and here is the page which throws the exception:
if(request.getParameter("none")==null)
throw new com.myserver.DateNotFoundException("Invalid Date");

and finally the error.jsp
<%
out.println("<h3>You landed in an Exceptional Condition!</h3>");
out.println("<b>Status Code </b>"+request.getAttribute("javax.servlet.error.status_code"));
out.println("<b>Exception Type </b>"+request.getAttribute("javax.servlet.error.message"));
out.println("<b>Message </b>"+request.getAttribute("javax.servlet.error.exception_type"));

%>


The problem is that I get to see the Tomcat generated error page and not mine!

Pls. help...
Thanks
Reema
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few things to check first:

(1) You have inserted the <error-page> into the correct place in the DD (this shouldn't be a problem because if the Schema weren't matched correctly, the application wouldn't have deployed successfully). Check the order of your elements as well.

(2) Check you have definitely deployed the error.jsp page to the application root (sounds stupid I know, but I've forgotten to do things like that myself before now!).

(3) Check the Tomcat error logs to see if there's actually another exception being thrown or if your error.jsp page is failing to translate (this would cause Tomcat to show its own page or raise another error).

(4) If all this seems fine, try changing the <exception-type> to java.lang.RuntimeException and see what happens then! If this works okay, think about narrowing down your search based on the fact the error page is being invoked correctly, but the exception you're throwing isn't being caught correctly. If it's not working then, check all the logs once again.

Let us know how you get on...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic