• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

error-page tag facing problem

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic