tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: reference to external error-page
Date Fri, 03 Jan 2003 14:17:50 GMT
Well, you can't do it directly with an error page, the <location> element's body
is required to contain an application-relative resource. Since you're using TC
4.x, you could take adavantage of JSTL to do something like:

web.xml:
<error-page>
  <error-code>404</error-code>
  <location>/error/404.jsp</location>
</error-page>

/error/404.jsp:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<c:import url="/error/404.html" context="/otherContext"/>

This is equivalent to using the following in a servlet:

ServletContext foreign = getServletContext().getContext("/otherContext");
RequestDispatcher rd = foreign.getRequestDispatcher("/error/404.html");
rd.include(request, response);

So, the error page is still part of the app, it just imports a foreign resource
to display the error message. Will that work for what you want to do?

Quoting Michael Mendelson <mmendelson@intowndenver.com>:

> 
> Hello all,
> 
> I would like to use an error page for certain apache/httpd errors as well
> as
> tomcat errors (e.g. 404). In the web.xml file though, the directive...
> 
> --------------------------------------------------------------------------------
>    <error-page>
> 	<error-code>404</error-code>
> 	<location>/error/404.html</location>
>    </error-page>
> --------------------------------------------------------------------------------
> 
> ...routes me to http://localhost/projectname/error/404.html.
> 
> How would I route to an error page location that might be on the same
> server,
> but external to the project?
> 
> I'm using Apache 1.3.23 and Tomcat 4.1.18 (and mod_jk to route requests to
> tomcat), if it matters.
> 
> Thanks,
> 
> Michael
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:tomcat-user-help@jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message