This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Custom Error Page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom Error Page" Watch "Custom Error Page" New topic
Author

Custom Error Page

Sangeetha Selvaraj
Greenhorn

Joined: Jan 12, 2004
Posts: 17
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

Joined: Jan 12, 2004
Posts: 17
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
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
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?


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Sangeetha Selvaraj
Greenhorn

Joined: Jan 12, 2004
Posts: 17
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
Mike Firkser
Ranch Hand

Joined: Oct 21, 2003
Posts: 247

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)


Mike Firkser
Rutgers '84
Sangeetha Selvaraj
Greenhorn

Joined: Jan 12, 2004
Posts: 17
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

Joined: Oct 21, 2003
Posts: 247

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.
 
wood burning stoves
 
subject: Custom Error Page
 
Similar Threads
problem with errorPage and isErrorPage="true"
Question on Page Directive
HFSJ Page 471:
Handling session timeout with errorPage
problem while declaring error page