You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tommy Wareing <pw...@brookes.ac.uk> on 2005/04/05 17:39:43 UTC

JSP error trapping?

I'm using 1.2.4, with Tiles. (I don't know whether Tiles is relevant, but  
you might as well know!)

I've got
   <global-exceptions>
     <exception key="error.general"
                type="java.lang.Exception" path="/WEB-INF/globalError.jsp"/>
   </global-exceptions>
in my struts-config.xml, which catches exceptions in my Action classes,  
and redirects them to an error page.

But if I make a mistake in a tile, such as referring to a non-existant  
bean, or property, I still get a stack trace thrown back to the user.

eg. if I add a spurious <bean:write name="fred"/> I get a page showing:
   500 Internal Server Error
   javax.servlet.jsp.JspException: Cannot find bean fred in any scope
   at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:992)
   at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:227)
   at _web_2d_inf._pages._login._jspService(login.jsp:9)
   [/WEB-INF/pages/login.jsp]
   at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
   ...

Any suggestions as to whether I can configure Struts to capture this  
(rather than configuring the container, which I also don't know how to  
do!)?

-- 
Tommy

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


Re: JSP error trapping?

Posted by Tommy Wareing <pw...@brookes.ac.uk>.
On Tue, 5 Apr 2005 10:45:59 -0600, Joe Germuska <Jo...@germuska.com> wrote:

> There's really not much Struts can do at this point, because control has  
> been transferred to the JSP.

Yeah, thought that might be the case.

> About the best you can do is judicious application of the JSTL c:catch  
> tag.

That may well do the trick. At least, it gives me something to look at.

> In this case, you could also use c:out instead of bean:write and at  
> least it wouldn't throw an exception; it would just not include any  
> content.

Fair comment: it was a quick hack to generate some error text.

Actually, at this point in development, it's quite convenient having  
exceptions thrown in *my* browser, because it's an indication that I've  
made some kind of mistake. But it's a bit nasty to pass on to the users.

-- 
Tommy

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


Re: JSP error trapping?

Posted by Joe Germuska <Jo...@Germuska.com>.
At 4:39 PM +0100 4/5/05, Tommy Wareing wrote:
>I'm using 1.2.4, with Tiles. (I don't know whether Tiles is 
>relevant, but you might as well know!)
>
>I've got
>   <global-exceptions>
>     <exception key="error.general"
>                type="java.lang.Exception" path="/WEB-INF/globalError.jsp"/>
>   </global-exceptions>
>in my struts-config.xml, which catches exceptions in my Action 
>classes, and redirects them to an error page.
>
>But if I make a mistake in a tile, such as referring to a 
>non-existant bean, or property, I still get a stack trace thrown 
>back to the user.
>
>eg. if I add a spurious <bean:write name="fred"/> I get a page showing:
>   500 Internal Server Error
>   javax.servlet.jsp.JspException: Cannot find bean fred in any scope
>   at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:992)
>   at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:227)
>   at _web_2d_inf._pages._login._jspService(login.jsp:9)
>   [/WEB-INF/pages/login.jsp]
>   at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
>   ...
>
>Any suggestions as to whether I can configure Struts to capture this 
>(rather than configuring the container, which I also don't know how 
>to do!)?

There's really not much Struts can do at this point, because control 
has been transferred to the JSP.

About the best you can do is judicious application of the JSTL c:catch tag.

In this case, you could also use c:out instead of bean:write and at 
least it wouldn't throw an exception; it would just not include any 
content.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

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