My recollection is that Web servers try each component on a path to see
if it is a file or directory, stop when a file is found, and pass the
rest as "extra information". Correct me if that is not what we are
talking about.
With query strings, you'd just have something like "/show?user" or
"/show?group", and Struts would render that as "/execute/show?group" or
"/show.do?group" -- but I take it that the point is that query strings
aren't an option here (because of a proxy server or something).
As it stands, I don't believe the ActionMappings used by the
ActionController can distinguish between URI's with extra information
and those without. Since the Mappings are virtual, there's no way to
tell where the "file path" ends and the extra information begins.
It's important to note that show in the example is not a Servlet -- it's
a multithreaded Action that is managed by the single ActionServlet in
your application. So, we would need a way for the Controller to pass
extra information along to the Action, perhaps bundled as request
parameters. This way /file/extra/information and /file?extra&information
would be equivalent.
I'm not sure if this would be a good idea or not, but one thing would be
to allow wildcards in Action paths, so that /show/* could match any URI
beginning with show, with the remainder being placed in the request as
parameters.
Also without stating an opinion, being able to specify */display as an
actin path could address Jonathan's question from the otehr day.
In either case, the ActionMapping could first be checked for an exact
match, with the wildcards being checked when an exact match wasn't
found.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
Tim Trentham wrote:
>
> I'm trying to use extra path info as a way to pass parameters to my actions.
> I changed the mapping from the default *.do to something like /execute/*.
> This works fine except that if I add extra information and try to submit, I
> get a 400 error telling me that I have submitted an invalid path.
>
> For example, I had a mapping called show.do which has now been changed to
> /execute/show. Now, if I try to submit /execute/show/user, expecting to have
> "user" passed to the show servlet as part of the extra path info accessed by
> request.getPathInfo(), I get the invalid path error. It works if I add
> another action mapping in the struts-config.xml that looks like this
>
> <action path="/show/user" type="com.mypackage.ShowAction">
> <forward name="/show/user" path="/WEB-INF/jsp/user.jsp"/>
> </action>
>
> This means that I have to have a separate action mapping for each different
> thing that I'd like an action to perform even though they're using the same
> action.
>
> I was expecting to be able to have something like this in the
> struts-config.xml:
>
> <action path="/show" type="com.mypackage.ShowAction">
> <forward name="/show/user" path="/WEB-INF/jsp/user.jsp"/>
> <forward name="/show/group" path="/WEB-INF/jsp/group.jsp"/>
> </action>
>
> Instead, I have to do this:
>
> <action path="/show/user" type="com.mypackage.ShowAction">
> <forward name="/show/user" path="/WEB-INF/jsp/user.jsp"/>
> </action>
>
> <action path="/show/group" type="com.mypackage.ShowAction">
> <forward name="/show/group" path="/WEB-INF/jsp/group.jsp"/>
> </action>
>
> The idea behind this is that I can have one action that basically just
> passes through the extra path info and forwards to the correct page based on
> that info.
>
> Is there another way to set this up so that you don't have to have an action
> mapping that matches the extra path info?
>
> Thanks.
>
> Tim