You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Nelson, Laird" <La...@FMR.COM> on 2002/11/22 18:18:16 UTC

servletMapping field in ActionServlet (1.0.2)

Hi; I'm looking at the v1.0.2 ActionServlet's addServletMapping() method,
and I'm noticing that it only handles the case where the ActionServlet has
one servlet mapping associated with it.  But it's legal (is it not?) to
establish several servlet mappings for a Servlet under the 2.2 spec, right?

In our case, we have an ActionServlet that is currently set up to handle
several different paths.  These paths are not really important to the
Actions per se, but (depending on various factors) may be important for
reporting purposes (i.e. did the person get into the website via path A,
path B or path C, even though all will route him to ActionA).  The Form tag
seems to be the only Struts tag that uses the servletMapping attribute.
Because the addServletMapping() method only ever takes the last mapping it
finds, it will always look (if I'm reading the code right) like all requests
that make use of the Form tag were submitted to path C.

Is there a simple workaround for this, or should I look into submitting a
patch?  Or should I just not worry about it?  :-)

Thanks kindly and happy Friday.

Laird

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: servletMapping field in ActionServlet (1.0.2)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 22 Nov 2002, Nelson, Laird wrote:

> Date: Fri, 22 Nov 2002 12:18:16 -0500
> From: "Nelson, Laird" <La...@FMR.COM>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: "'struts-dev@jakarta.apache.org'" <st...@jakarta.apache.org>
> Subject: servletMapping field in ActionServlet (1.0.2)
>
> Hi; I'm looking at the v1.0.2 ActionServlet's addServletMapping() method,
> and I'm noticing that it only handles the case where the ActionServlet has
> one servlet mapping associated with it.  But it's legal (is it not?) to
> establish several servlet mappings for a Servlet under the 2.2 spec, right?
>

It's definitely legal from the servlet spec perspective, but not from the
Struts ActionServlet perspective.  Struts currently does not know how to
reliably compute URLs for things like <html:form> in the face of more than
one mapping.

> In our case, we have an ActionServlet that is currently set up to handle
> several different paths.  These paths are not really important to the
> Actions per se, but (depending on various factors) may be important for
> reporting purposes (i.e. did the person get into the website via path A,
> path B or path C, even though all will route him to ActionA).  The Form tag
> seems to be the only Struts tag that uses the servletMapping attribute.
> Because the addServletMapping() method only ever takes the last mapping it
> finds, it will always look (if I'm reading the code right) like all requests
> that make use of the Form tag were submitted to path C.
>

A subtle point needs to be remembered -- from the client viewpoint, the
URL you *submit* to (i.e. the action) is what shows in the Location bar
on a browser.  Since the Action that is invoked can return an
ActionForward to *any* page, the same URL can literally display anything.
This applies to any scenario that uses RequestDispatcher.forward(), not
just to Struts.

More fundamentally, then, I would contend that the absolute value of a URL
is totally meaningless in a web application based on an MVC architecture
that uses RD.forward() the way Struts uses it.  They are simply an
internal implementation detail of the communication, and have no meaning
in and of themselves.

Web Applications != Web Sites

> Is there a simple workaround for this, or should I look into submitting a
> patch?  Or should I just not worry about it?  :-)

There is not going to be a useful workaround for this -- it's fundamental
to the nature of the architecture.

>
> Thanks kindly and happy Friday.
>
> Laird

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: servletMapping field in ActionServlet (1.0.2)

Posted by Ted Husted <hu...@apache.org>.
It occured to me that we may have gotten off track on this thread.

The restriction that Struts 1.0.x places on URIs is that there can 
only be only one servlet mapping (and only one ActionServlet). 

Of course, if you are using extension mapping, then any *.do (or 
whatever) URI will be processed against the ActionMappings. 

You can have as many mappings as you like that all point to the 
same resources. So there can be mappings for pathA, B, and C, that 
all reference ActionA. 

If the paths you are used to looking at live on the left side of 
the dot, then you can just have duplicate ActionMappings for each 
path. Perhaps before these paths ended in *.jsp and now they will 
end in *.do, but that might not matter. 

If it did, I have heard of people doing things like changing the 
JavaServerPages service to use another extension and then mapping 
*.jsp to the ActionServlet. Though, I've never tried this myself 
=:)

As along as you can live with a consistent extension mapping 
throughout your application, then the rest of URI is yours to 
mangle as you please. The ActionMapping just sees it as an 
arbitrary string that it associates with an ActionMapping 
decorator. The ActionMapping decorator can in turn reuse whatever 
Actions, pages, and other resources you like.

Of course, the next question might be "How can I get the same 
html:form tag to submit to different ActionMappings (to retain the 
different paths)?" You can, but it's not pretty -- I think I feel 
a tip coming on =:0)

-Ted.


11/22/2002 12:18:16 PM, "Nelson, Laird" <La...@FMR.COM> 
wrote:

>Hi; I'm looking at the v1.0.2 ActionServlet's addServletMapping() 
method,
>and I'm noticing that it only handles the case where the 
ActionServlet has
>one servlet mapping associated with it.  But it's legal (is it 
not?) to
>establish several servlet mappings for a Servlet under the 2.2 
spec, right?
>
>In our case, we have an ActionServlet that is currently set up to 
handle
>several different paths.  These paths are not really important to 
the
>Actions per se, but (depending on various factors) may be 
important for
>reporting purposes (i.e. did the person get into the website via 
path A,
>path B or path C, even though all will route him to ActionA).  
The Form tag
>seems to be the only Struts tag that uses the servletMapping 
attribute.
>Because the addServletMapping() method only ever takes the last 
mapping it
>finds, it will always look (if I'm reading the code right) like 
all requests
>that make use of the Form tag were submitted to path C.
>
>Is there a simple workaround for this, or should I look into 
submitting a
>patch?  Or should I just not worry about it?  :-)
>
>Thanks kindly and happy Friday.
>
>Laird
>
>--
>To unsubscribe, e-mail:   <mailto:struts-dev-
unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:struts-dev-
help@jakarta.apache.org>
>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>