Struts exception handling with tiles

S

stu

Hi there,

I'm using declarative exception handling with struts 1.3 using the
<global-exceptions> element as follows:-

<global-exceptions>
<exception key="error.exception.invalidMagazine"
type="java.lang.Exception"

handler="com.dovetailservices.sol3.services.exception.Sol3ExceptionHandler"
path="/WEB-INF/pages/error.jsp">
</exception>
</global-exceptions>

This works fine, however instead of forwarding to a jsp (error.jsp)
I'd like to forward to a tiles definition when an exception is caught,
like so:-

<global-exceptions>
<exception key="error.exception.invalidMagazine"
type="java.lang.Exception"

handler="com.dovetailservices.sol3.services.exception.Sol3ExceptionHandler"
path=".error">

</exception>
</global-exceptions>

However this doesn't work. Is there any way of getting this working?

Thanks in advance,
Stuart
 
S

stu

Ok I've found a way around this....

Instead of trying to forward to a tiles definition, I forwarded to a
jsp containing a tiles implementation of a tiles layout:-

So in struts-config.xml we have:-
<global-exceptions>
<exception key="error.exception.invalidMagazine"
type="java.lang.Exception"

handler="com.dovetailservices.sol3.services.exception.Sol3ExceptionHandler"
path="/WEB-INF/pages/error.jsp">
</exception>
</global-exceptions>


Where error.jsp is as below, implementing a tiles layout jsp called
main_layout.jsp:-

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

<tiles:insert page="/WEB-INF/templates/main_layout.jsp"
flush="true">
<tiles:put name="title" value="error" />
<tiles:put name="body" value="/WEB-INF/pages/body.jsp" />
<tiles:put name="footer" value="/WEB-INF/pages/footer.jsp" />
</tiles:insert>


This isn't as neat as using a tiles definition in tiles-defs.xml but
it does the job.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top