0

Here is my web.xml structure:

    <servlet>
        <servlet-name>myServlet</servlet-name>
        <servlet-class>com.test.servlet.MyServlet</servlet-class>       
    </servlet>

    <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/testServlet/*</url-pattern>
    </servlet-mapping>

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

   <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

<filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

In Jsp, I called the servlet like below.

<img src="${pageContext.request.contextPath}/testServlet?id=${someID}"

The problem is when I used like below, the servlet is called. When I changed *.jsp to /* in fliter mapping, it failed to call the servlet.

   <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping>

but when I use *.jsp, then the calender using struts2-dojo plugin doesn't appear in jsp.

Roman C
  • 49,761
  • 33
  • 66
  • 176
kitokid
  • 3,009
  • 17
  • 65
  • 101

2 Answers2

1

You can exclude particular request path from handling it by Struts 2

Preventing Struts from Handling a Request

Lukasz Lenart
  • 987
  • 7
  • 14
0

You need to exclude myServlet mapping so that is does not pass from the filter dispatcher of struts.

In your struts.xml add:

<constant name="struts.action.excludePattern" value="/ServletToExcludeFromStruts*"/>

The value be comma delimited as well for multiple exclusions.

See http://struts.apache.org/2.2.1/docs/webxml.html ..

Help taken from this link.

Community
  • 1
  • 1
HashimR
  • 3,803
  • 8
  • 32
  • 49