You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fred Toth <ft...@synernet.com> on 2008/09/19 16:03:14 UTC

Solution to integrating error-page with struts2

Hi all,

I had problems trying to get tomcat to forward to a struts2 action
from an <error-page> directive in web.xml. I was all set to run to
the list for help when I figured it out. I thought I'd post this anyway
in case it helps someone else.

I had error-page working in the simplest sense. If I pointed it toward
a plain HTML file, it worked fine. But if I tried going to a struts action,
I got strange behavior and the action never fired.

Then I read in the servlet spec that error-page forwarding doesn't go 
through
filters unless you use the <dispatcher> mechanism. And, sure enough,
struts2 is implemented as a filter. Once I added:

<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>

to the struts filter-mapping, everything worked.

The problem I was trying to solve: I'm using DefaultServlet to serve lots
of resources on my site. However, I needed a general purpose "not found"
handling mechanism. So if we forward a request to DefaultServlet for
a resource that doesn't exist, I want to trap that in my struts 2 "not 
found"
action.

Thanks.

Fred

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org