wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes error-page tag  facing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "error-page tag  facing problem" Watch "error-page tag  facing problem" New topic
Author

error-page tag facing problem

satya mahapatra
Ranch Hand

Joined: Jan 07, 2006
Posts: 134
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


Regards,<br />Satya<br />SCJP,SCWCD
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
satya mahapatra
Ranch Hand

Joined: Jan 07, 2006
Posts: 134
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.
 
subject: error-page tag facing problem