Annie
Annie

Reputation: 69

A blank page is show instead of error page for exception in JSP

I need to setup a general error page for my jsp program, I test it by making a general error page, then having <%@ page language="java" errorPage="error.jsp" %> at the first line of a jsp page, then create an exception in the page, but just a blank page is show instead of forward to general error page. I guess there is some setting problem? Thanks for your help.

Upvotes: 0

Views: 914

Answers (1)

Angelo Oparah
Angelo Oparah

Reputation: 673

Assuming you have something like this in your web.xml

<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/errorpage.jsp</location>
</error-page>

Or for instance in case of 404

<error-page>
    <error-code>404</error-code> 
    <location>/errorpage.jsp</location>
</error-page>

Try adding the isErrorPage attribute within the page directive on top of your errorpage.jsp and set it to "true"

<%@ page contentType="text/html; charset=ISO-8859-1 " isErrorPage="true" %> 

Upvotes: 1

Related Questions