You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ryan Lubke <Ry...@Sun.COM> on 2001/07/06 21:29:21 UTC

Re: How to configure a custom page for JSP 404 errors?

Hi Pierce,

 From what I've been able to gather, you should be able to set
the error page using the <error-page> directive within the
deployment descriptor for a web app (web.xml).

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

Looking through the bug database, there was an open issue
regarding the use of static html pages within the <location>
tag.  I'm uncertain at this time what release it's actually fixed
in, but if you try it and get a stacktrace, then I guess you know :)

The bug report can be found here:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=291

I did find this information in the archives.  
Try looking at the results of the following search:
http://mikal.org/interests/java/tomcat/archive/search?search=error+page+custom+404

I'm sure those who are more experiences could expand/correct on this 
information.
Hope this helps.

-rl

Courtney, Pierce wrote:

>Hello,
>
>This question probably has come up before, I just can't find it in the
>archives....
>
>I am using Tomcat 3.2.2 standalone (not with Apache).
>
>How can I configure a particular page (servlet, static html, or jsp) to be
>the "default"
>page that comes up if the requested jsp is not found, instead of the 404
>error.
>In other words, if a user requests:
>http://myTomcatSite.com/somePage.jsp
>
>I want to have somePage.jsp come up if it exists.
>But if somePage.jsp does not exist, I *don't* want the default 404 error to
>be displayed. Instead I want some custom page (a servlet actually) to be
>processed. I don't really care if this is achieved with a client-side
>redirect or a server-side include/forward.
>
>I have tried using the DefaultServlet, which doesn't seem to work. I have
>also set up my own servlet against <url-pattern> /* </url-pattern>. This
>works for servlets only, not JSPs. It seems the basic problem is that any
>URI that matches *.jsp. gets processed by the JspServlet.  So it is not
>determined if the .jsp file actually exists or not until the JspServlet is
>triggered.
>
>Can this custom error page functionality be configured somehow in Tomcat?
>
>Thanks for any help,
>Pierce Courtney
>pcourtney@ea.com
>
>