Win a copy of Java Challengers this week in the Java in General forum!
  • 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
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Custom Error Page

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Iam aware that u have to include the page directive in the page where the error is generated so that it is forwarded to a jsp error page which has the directive "isErrorPage="true"...but doesnt seem to be working...
my html is in "c:\tomcat\webapps\app-name\subfolder" with the page directive before the <html> tag.
<%@ page errorPage="/subfolder/show_error_page.jsp" %>
my error page is in the same folder too named "show_error_page.jsp" with the foll code
<html>
<body>
<%@ isErrorPage = "true" %>
this is a custom error page
<p><i> <%= exception %> </i>
<body>
</html>
iam not sure where the mistake is...Greatly appreciate the help
 
Sangeetha Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also read in one of the prevs messages that the page directive in the html page should be above the html tag...i tried it as the first line in body and before html too...confused as to what is right
<%@ page errorPage="show_error_page.jsp" %>
before html tag or first line of body tag???
sorry for the 2nd post
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sangeetha,
can you please tell, which exception gets generated in your main jsp page? Also if the control doesn't go to error page (when exception is generated), what is displayed? and lastly are you using try-catch in your main jsp?
 
Sangeetha Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prakash,
actually iam the one inducing the error for testing purposes...iam not using try catch..iam just trying to write to a file and so for testing i made it read only....so that an exception is created and i can see my custom error page..its status 500 error
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.io.FileNotFoundException: C:\Tomcat 5.0\webapps\murach\WEB-INF\etc\UserEmail.txt (Access is denied)
hope this helps
 
Ranch Hand
Posts: 249
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think your error is in your error page tag.
You have:
<%@ isErrorPage = "true" %>
I think it should be
<%@ page isErrorPage = "true" %>
(You forgot the "page" in the tag on the error page)
 
Sangeetha Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks mike, i tried it out but same result...am i making a mistake in the path while calling for the error jsp file?....plz refer to my first post...
thanks again
 
Mike Firkser
Ranch Hand
Posts: 249
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was playing around with this earlier today, so some of the problems are fresh in my mind.
First, make sure your current page works. Remove your errors and make sure there aren't other errors masking your error. Then put in your error--and make it simple, maybe an SQL error or something like that. For the error page reference, try both relative and absolute paths.
Hope this helps.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic