I have added a filter mapping. See the second sentence of the original post.

The problem is that according to the Servlet Spec (at least my understanding of it) "Filters can be associated with groups of servlets and static content using the <url-pattern> style of filter mapping". Since the Struts actions aren't static content (they may however end up serving static content) and I don't have any servlet mappings that would match for instance "HelloWorld.action" it appears my only
option is to make a "No-Op" servlet and map is to "/*".

The problem with the "No-Op" servlet is that I won't receive 404s anymore. I
suppose that instead of a "No-Op" servlet I could make a "404" servlet.

Jeromy Evans wrote:
I have plenty of S2 webapps that don't include a servlet in web.xml and haven't encountered this problem. Have you included a filter mapping instead?

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; >

<filter>
       <filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
  <filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

Danny Hurlburt wrote:
Hello,

I am using Tomcat 5.5 as my servlet container. I have added the
org.apache.struts2.dispatcher.FilterDispatcher as a filter with
a url pattern of /*.

   <filter>
       <filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
   </filter>

When following the HelloWorld example on the Strut's wiki
(http://struts.apache.org/2.x/docs/hello-world.html) I
could not get the filter to run. I set a break point in
the doFilter method. Then I would call
http://localhost:8080/cntxPath/HelloWorld.action
but the filter is never invoked. The filter is however
invoked if I request
http://localhost:8080/cntxPath/HelloWorld.jsp since
this request maps to the JSP servlet (but of course
the filter won't invoke an action class and will
simply let the JSP servlet write to the response).

The problem seems to be that since I don't have any
servlet mappings that will match
http://localhost:8080/cntxPath/HelloWorld.action the
filter is never invoked.

I don't have Tomcat's "default" servlet (which is mapped
to /) enabled. However when I do enable this, the request
http://localhost:8080/cntxPath/HelloWorld.action causes
the filter to be invoked an it attempts to find an
action mapping to HelloWorld.

I have read the Servlet 2.4 spec and it sounds like
filters will only be called if the URI matches some servlet
mapping AND the URI matches the filter mapping. Since I
don't have a servlet that would get invoked using
http://localhost:8080/cntxPath/HelloWorld.action the
Struts filter never gets invoked (unless I enable Tomcat's
default servlet which I don't want to do). It sounds like
Tomcat is doing what it suppose to do by not invoking the
Struts filter because there are no servlets matching any
servlet mappings.

I believe I can solve this problem with a No-op servlet
mapped to /*. This would be similar to enabling Tomcat's
default servlet.

Has anybody else ran into this problem? Anybody have any
solutions?

Thanks,

Dan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to