On Sat, 14 Dec 2002, Manomohan K Kalathil wrote: > Date: Sat, 14 Dec 2002 19:35:43 +0530 > From: Manomohan K Kalathil <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: More than one servlet mapping > > Hi all, > The struts documentation > (http://jakarta.apache.org/struts/userGuide/configuration.html#dd_config) > says that "WARNING - Struts will not operate correctly if you define more > than one <servlet-mapping> element for the controller servlet." > I would like to know the reason behind this. Is it that the > controller will not be able to differentiate between request to similar URLs > which differ by the extension ? > Let us take a simple example, suppose I were to map the action to two > extensions, as in: > > <servlet-mapping> > <servlet-name>action</servlet-name> > <url-pattern>*.do</url-pattern> > </servlet-mapping> > <servlet-mapping> > <servlet-name>action</servlet-name> > <url-pattern>*.act</url-pattern> > </servlet-mapping> > > One would think that the Action Servlet will have trouble in figuring > out how to handle the following URLs > http://hostname/context/getBalance.do and > http://hostname/context/getBalance.act. This is because the action mapping > does not contain the extensions. > <action path="/getBalance" type="com.myco.BalanceAction" /> > > Is there any other known issue in the use of more than one mapping to the > action servlet.
Yes. It won't work :-). The problem isn't on the incoming requests being mapped to the controller servlet correctly -- it's when Struts is asked to dynamically generate a URL for an action (such as in an <html:form> tag). There is no easy way to tell which of the mappings should be used, and also some pathological cases where the application treats requests with the different extensions differently (which Struts would know nothing about). Although advanced users might be able to craft a combination of things that would work, it would be a quicksand trap for mere mortals. Therefore, Struts only remembers a single mapping pattern for the controller servlet. > > Regards > Mano > Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

