On Fri, 15 Jun 2001, Jamie Tsao wrote:

> Hi,
> 
> I'm having some trouble understanding how the extension mapping works
> for servlets and struts.  In the web.xml file, the following extension
> mapping for the struts ActionServlet is used:
> 
>   <servlet-mapping>
>     <servlet-name>ActionServlet</servlet-name>
>     <url-pattern>*.do</url-pattern>
>   </servlet-mapping>
> 
> 
> I understand that any request URIs that end with .do will be passed to
> the ActionServlet.

That is correct.

>  What I don't understand is where the .do extension
> is even attached.  All of my forms have an action of /login or
> /checkout, for example.  I "could" specify /login.do or /checkout.do,
> but I'm not.  So what I don't understand is why do these requests still
> get mapped to the ActionServlet ?  Is ".do" being attached to the
> request URI somehow and where ?  when ?
>

The basic idea is that Struts works equally well when you use extension
mapping (*.do) or path mapping (/do/*), so you should have to make minimal
changes to change your mind.  Therefore, all of the references to a
particular action path in the struts-config.xml file can be made without
the ".do" extension -- and the <html:form> tag will add the extension if
necessary -- so that you generally don't have to think about it.

If you're creating your own hyperlinks or <forward> definitions, you
currently do need to include the complete path.
 
> I just need this little bit clarified.
> 
> Thanks,
> 
> Jamie
> 

Craig


Reply via email to