See below...

> -----Original Message-----
> From: Fernando Martins [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 28, 2003 10:22 AM
> To: [EMAIL PROTECTED]
> Subject: [OS-webwork] [OS-webwork2] mapping actions without .action
> 
> 
> 
> Assuming that I have in xwork an action named "bar" inside a 
> package with namespace "foo/" if I want to map the follow 
> request to ServletDispatcher:
> 

Off topic, but the bug that made namespaces like "foo/" has been fixed.
It's now "/foo".

> http://my.com/foo/bar  ( and not http://my.com/foo/bar.action)
> 
> I assume that in web.xml should be:
> 
>    <servlet-mapping>
>       <servlet-name>webwork2</servlet-name>
>       <url-pattern>/*</url-pattern>
>    </servlet-mapping>
> 
> The problem is that request.getServletPath() (in 
> ServletDispatcher) will return "" (normally would return 
> "/foo/bar.action", if the mapping would be *.action).
> 
> I tried with JETTY and ORION, and while ORION will work with
> 
> <url-pattern>*</url-pattern>
> 
> (work means that getServletPath returns the 'correct' path: 
> "/foo/bar")
> 
> JETTY doesn't accept such url-pattern. So I don't know which 
> container follows more closely the SPEC.
> 
> How can I anchieve my purpose in both JETTY & ORION?
> 
> I checked that when using url-pattern /* getServletPath() 
> returns "", but request.getPathInfo() returns "/foo/bar" 
> which if used in the following processing (instead of using 
> what getServletPath() returns) will find the action "bar" and 
> call it, which is what I need.

I believe this is correct. I think getServletPath() is supposed to
return the part of the path that matched the mapping, and getPathInfo()
returns the rest... Of course, it's been a while since I read through a
servlet spec :-) This could also be 2 different interpretations of an
ambiguous spec. 

Anyone know for sure?

Regardless, the fact that this works differently in 2 different servlet
containers says that you'll probably have to have a hack in your custom
dispatcher to handle both.

> 
> So would it be possible to add the following lines to 
> ServletDispatcher?
> 
>       if (actionPath.length()==0){
>               actionPath = request.getPathInfo();
>               servletPath = actionPath;
>       }
> 
> Or is there another more elegant solution to this?
> 

You're going to need a custom dispatcher to support this. The
ServletDispatcher has been designed for mapping to an extension. That
said, I think it might be good to provide another dispatcher for WW2
that uses everything up to the last "/" as the namespace, and the part
after the last "/" as the action name. 

Jason


-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to