This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
Joined: Sep 25, 2003
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.
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.
Joined: Sep 25, 2003
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