You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Nathan Coast <na...@codeczar.com> on 2003/07/13 11:39:18 UTC

tiles tags exception handling

Hi,

I've been having trouble getting exceptions handled usefully when they 
occur within jsps called via tiles:insert tags.

I've tracked the code down to:

org.apache.struts.taglib.tiles.InsertTag

where this exception handling code is called:

protected void processException(Throwable ex, String msg) throws 
JspException {
   try {
     if (msg == null)
       msg = ex.getMessage();
     if (log.isDebugEnabled()) { // show full trace
       log.debug(msg, ex);
       pageContext.getOut().println(msg);
       ex.printStackTrace(new PrintWriter(pageContext.getOut(), true));
     } else { // show only message
       pageContext.getOut().println(msg);
     } // end if
   } catch (IOException ioex) { // problems. Propagate original exception
     pageContext.setAttribute(
       ComponentConstants.EXCEPTION_KEY,
       ex,
       PageContext.REQUEST_SCOPE);
     throw new JspException(msg);
   }
}

my understanding of this code is that no exception will be passed to the 
enclosing jsp page.  If an excption occurs, a simple error message will 
appear in the enclosing page.  If debug is enabled for the Logger 
"org.apache.struts.taglib.tiles.InsertTag" then the stack is filled in 
too.  Am I right?

If so, would it be better to enable excptions to be cascaded up, 
enabling exception management in a more application specific manner? 
e.g. making use of the error-page elements in the web.xml

I'd like to be able to log the error centrally and display to the user a 
meaningful error page.

thanks
Nathan

p.s.  thanks to all the development team.  Struts seriously reduces 
devlopment time and increases the quality of applications built with it.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: tiles tags exception handling

Posted by Nathan Coast <na...@codeczar.com>.
excellent, thanks

David Graham wrote:
> This was a known problem that I've fixed for Struts 1.2.  You could also
> use a recent nightly build to pick up this fix.
> 
> David
> 
> 
> --- Nathan Coast <na...@codeczar.com> wrote:
> 
>>Hi,
>>
>>I've been having trouble getting exceptions handled usefully when they 
>>occur within jsps called via tiles:insert tags.
>>
>>I've tracked the code down to:
>>
>>org.apache.struts.taglib.tiles.InsertTag
>>
>>where this exception handling code is called:
>>
>>protected void processException(Throwable ex, String msg) throws 
>>JspException {
>>   try {
>>     if (msg == null)
>>       msg = ex.getMessage();
>>     if (log.isDebugEnabled()) { // show full trace
>>       log.debug(msg, ex);
>>       pageContext.getOut().println(msg);
>>       ex.printStackTrace(new PrintWriter(pageContext.getOut(), true));
>>     } else { // show only message
>>       pageContext.getOut().println(msg);
>>     } // end if
>>   } catch (IOException ioex) { // problems. Propagate original
>>exception
>>     pageContext.setAttribute(
>>       ComponentConstants.EXCEPTION_KEY,
>>       ex,
>>       PageContext.REQUEST_SCOPE);
>>     throw new JspException(msg);
>>   }
>>}
>>
>>my understanding of this code is that no exception will be passed to the
>>
>>enclosing jsp page.  If an excption occurs, a simple error message will 
>>appear in the enclosing page.  If debug is enabled for the Logger 
>>"org.apache.struts.taglib.tiles.InsertTag" then the stack is filled in 
>>too.  Am I right?
>>
>>If so, would it be better to enable excptions to be cascaded up, 
>>enabling exception management in a more application specific manner? 
>>e.g. making use of the error-page elements in the web.xml
>>
>>I'd like to be able to log the error centrally and display to the user a
>>
>>meaningful error page.
>>
>>thanks
>>Nathan
>>
>>p.s.  thanks to all the development team.  Struts seriously reduces 
>>devlopment time and increases the quality of applications built with it.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>>
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: tiles tags exception handling

Posted by David Graham <gr...@yahoo.com>.
This was a known problem that I've fixed for Struts 1.2.  You could also
use a recent nightly build to pick up this fix.

David


--- Nathan Coast <na...@codeczar.com> wrote:
> Hi,
> 
> I've been having trouble getting exceptions handled usefully when they 
> occur within jsps called via tiles:insert tags.
> 
> I've tracked the code down to:
> 
> org.apache.struts.taglib.tiles.InsertTag
> 
> where this exception handling code is called:
> 
> protected void processException(Throwable ex, String msg) throws 
> JspException {
>    try {
>      if (msg == null)
>        msg = ex.getMessage();
>      if (log.isDebugEnabled()) { // show full trace
>        log.debug(msg, ex);
>        pageContext.getOut().println(msg);
>        ex.printStackTrace(new PrintWriter(pageContext.getOut(), true));
>      } else { // show only message
>        pageContext.getOut().println(msg);
>      } // end if
>    } catch (IOException ioex) { // problems. Propagate original
> exception
>      pageContext.setAttribute(
>        ComponentConstants.EXCEPTION_KEY,
>        ex,
>        PageContext.REQUEST_SCOPE);
>      throw new JspException(msg);
>    }
> }
> 
> my understanding of this code is that no exception will be passed to the
> 
> enclosing jsp page.  If an excption occurs, a simple error message will 
> appear in the enclosing page.  If debug is enabled for the Logger 
> "org.apache.struts.taglib.tiles.InsertTag" then the stack is filled in 
> too.  Am I right?
> 
> If so, would it be better to enable excptions to be cascaded up, 
> enabling exception management in a more application specific manner? 
> e.g. making use of the error-page elements in the web.xml
> 
> I'd like to be able to log the error centrally and display to the user a
> 
> meaningful error page.
> 
> thanks
> Nathan
> 
> p.s.  thanks to all the development team.  Struts seriously reduces 
> devlopment time and increases the quality of applications built with it.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org