You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Deadman, Hal" <ha...@tallan.com> on 2001/01/16 22:57:15 UTC

errorPage directive with templates, exception handling

When I am using Struts templates, and I want to set an errorPage in the page
tag like so:

<%@ page language="java" session="false" buffer="16kb" autoFlush="true"
errorPage="/error.jsp" %>

Does this errorPage definition need to be placed on:
a. every page included by the template, or
b. the page that defines the template, contains <template:get, or
c. the page that uses the template, contains <template:insert and
<template:put


On a somewhat related note, I am still trying to get a handle on proper
exception handling in JSPs that use tags. It seems like the root exception
gets lost when a tag re-throws a JSPException instead of a ServletException.
Why don't JSPExceptions allow you to nest the exception that caused them? In
the struts code I sometimes see exceptions getting put in the pageContext
before a JSPException is re-thrown but this seems like it might cause
problems.

snippet from GetTag.java:

            catch(Exception ex) {
               pageContext.setAttribute(Action.EXCEPTION_KEY, ex,
                                        PageContext.REQUEST_SCOPE);
               throw new JspException(ex.getMessage());

If you have nested tags, won't the exception get overwritten in the
pageContext so that the original exception is lost?

Finally, and this isn't related to struts, does anyone know if the
error-page tag from web.xml superscedes the errorPage page directive? Are
they related in any way?

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

Thanks for any help.