I had the same question last week (and for some reason did not get any
response from
the mailing list?)  ... anyway, it seems to me that Struts really does not
handle multiple
servlet mappings for the ActionServlet.  When using extension mappings,
Struts finds the action mapping to use by stripping off the ".do", or any
other extension, and using that as the path for determining the action
mapping.  I was trying to do a similar thing where *.do was the authorized
stuff, and *.go was to be the anonymous stuff ... it ended up that the
generated URLs always became *.go!  I think it is simply using the "last"
mapping specified.

My plan is to only use one extension mapping for my ActionServlet and come
up with a different mechanism for applying my security constraints.
Possibly by a vitual path where I would have 
*.do -> as my ActionServlet servlet mapping
Then I would use ...
/protected/*.do for restricted pages ...
Then I could set up a security constraint for "/protected/*"

My 2 cents ...

-----Original Message-----
From: Dave Allen [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 23, 2001 3:12 PM
To: [EMAIL PROTECTED]
Subject: problems mapping multiple ActionServlets


This might be more appropriate for the Tomcat user
list, but I'll try anyway.  I'm using Tomcat 3.2.2
and trying to map multiple ActionServlets in
web.xml.  I have a <servlet-mapping> for "*.do"
which I execute for the form action "search.do",
and everything works fine when this is the only
<servlet-mapping> in web.xml.  But as soon as I
add another <servlet-mapping> for "*.authDo", when
I try to execute "search.do", "search.authDo" is
called (it even appears in the URL), which I don't
understand since I don't call "search.authDo" from
anywhere in my page (or anywhere on the site).  If
I the change to added mapping to any name, like
"*.anything", "search.anything" is called . 

The pertinent code is below.  Many advanced
thanks.

Dave

>From the jsp:
            <form:form 
              action="search.do"
              name="caretoolSearchForm" 
             
type="com.getcare.servlet.CaretoolSearchForm">

>From web.xml:

    <servlet>
        <servlet-name>Action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>application</param-name>
           
<param-value>com.getcare.servlet.ErrorMessages</param-value>
        </init-param>
        <init-param>
            <param-name>config</param-name>
           
<param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>validate</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <servlet>
        <servlet-name>authAction</servlet-name>

<servlet-class>com.getcare.servlet.CaretoolActionServlet</servlet-class>
        <init-param>
            <param-name>application</param-name>
           
<param-value>com.getcare.servlet.ErrorMessages</param-value>
        </init-param>
        <init-param>
            <param-name>config</param-name>
           
<param-value>/WEB-INF/struts-auth-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>validate</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>authAction</servlet-name>
        <url-pattern>*.authDo</url-pattern>
    </servlet-mapping>

Reply via email to