On Fri, 14 Sep 2001, KL OOI wrote:

> Date: Fri, 14 Sep 2001 11:01:32 +0800
> From: KL OOI <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED], KL OOI <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: errorPage
>
> Hi,
>
> Do anyone here know how to use the following ?
>
> <%@ page errorPage="/jsp/kp/error.jsp?jsp=" + request.getRequestURI() %>
>
> i have put this on top of my JSP page but it seems like not divert me to the
> error.jsp.
> do i need extra configuration??
> any pointer for this??
>

The JSP specification, at <http://java.sun.com/products/jsp/download.html>,
and the servlet specification at
<http://java.sun.com/products/servlet/download.html>.

You cannot use a runtime expression here because the page directive is
evaluated at *compile* time, not at request time.

If you want access to the request URI of the offending page as part of the
error page, you should dispense with the errorPage attribute of the page
directive, and use the servlet API capabilities instead.  If you declare
the following in your /WEB-INF/web.xml file:

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

then your error page will be called on *any* exception thrown by any JSP
page or servlet (you can also have different error pages for different
exceptions or HTTP status codes, if you want).  Within the page, you can
access (among others) the following request attribute created by the
container:

  <%
    String requestURI = (String)
     request.getAttribute("javax.servlet.error.request_uri");
  %>

See the servlet spec chapter on Web Applications for more details.

> thanks...
>
> best regards,
> kl

Craig McClanahan


Reply via email to