Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error-page tag facing problem  RSS feed

 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to test the application given in HF to test <error-code> tag. But not able to figure out why this isn't working.

form.html
==========
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Test Error Page </TITLE>
</HEAD>
<BODY>
<form action="badPage.jsp">
<input type="submit" value="Submit" />
</form>
</BODY>
</HTML>

badPage.jsp
==============
<%@ page errorPage="errorPage.jsp" %>
<html>
<body>
Division result is::
<% int i = 10/5; %>
<%= i %>
<form action="errorPage.jsp">
<input type="submit" value="Submit" />
</form>
</body>
</html>

errorPage.jsp
===============
<%@ page isErrorPage="true" %>
<html>
<body>
Coming Inside ErrorPage.jsp
</body>
</html>

web.xml
=========
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/errorPage.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/errorPage.jsp</location>
</error-page>
</web-app>

This code is working fine. Control is going from badPage.jsp to errorPage.jsp.But when I am doing 10/0 in badPage.jsp it is showing page cannot be displayed.Its not displaying errorPage.jsp.

Any idea where I am doing the mistake.

Thanks,
Satya
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your web.xml will be completely ignored since your badPage specifies a page errorPage directive scriptlet. The directive trumps the web.xml.

Are badPage and errorPage in the same folder? If not, begin the URL with a / and given the appropriate path for finding the error page.
 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc,

When I removed errorPage directive scriptlet from errorPage.jsp its working fine. But when I am keeping both means scriptlet errorpage and web.xml entry ,its not working.

Anyway one way it work fine. Thanks for your help.

Thanks,
Satya
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!