This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Error in Tile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Error in Tile" Watch "Error in Tile" New topic
Author

Error in Tile

Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
I created a throwError.jsp page that simply throws an Exception. The page is the main body content tile, and it is surrounded my several menu related tiles. When I request the url that allows me to see throwError.jsp, all the tiles render just fine except for the throwError tile - it contains a log message that says a ServletException occurred. My problem is, I want any runtime exceptions that occur in throwError.jsp, or any other main body content tiles, to cause the main body content to be filled out with a custom error page. I've tried the following methods, but I still see the log message in the main body content section:

1) In web.xml

2) In struts-config.xml

3) Even tried a JSTL <c:catch> tag that I included in my layout that surrounded <tiles:get name="body" />

None of these methods worked. I'm still seeing the server's exception log. What can I do to see custom content in the main body section if an Exception occurs? Thanks a lot in advance.
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
As a last resort, I included

in my main body content tile and that allowed me to see all of my menu tiles just fine and my custom error content in the main body instead of the error log.

I am not happy with this solution though because it means that I must set the errorPage in all of my main body content tiles.

Does anyone know a workaround for this? Thanks.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

That's how it works in jsps AFAIK. If your Actions throw an exception it will be handled by your global-exception but an error on the jsp needs the errorPage for the redirect. I would argue that your jsp should be structured so that an exception can not occur as it should contain presentation logic and not business logic.


A good workman is known by his tools.
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
I would argue that your jsp should be structured so that an exception can not occur as it should contain presentation logic and not business logic.


It is structured that way, but I'm paranoid about potential errors in custom tags
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in Tile
 
Similar Threads
How use web.xml to set error page to grab all exceptions?
Global excpetion-getting print stack trace?
error handling in web.xml
How to handle JSP exceptions declaratively
404 prob.