That's a good question and I agree some guidance on servlet path and path
info would be useful.
Although not specified in the Http Service for a registration "/a" and
request "/a/b" it makes sense to have:
-servlet path of "/a"
-path info of "/b"
I'll open a bug.
For your question my feeling is that we should not treat a registration at
'/' any differently than other aliases. That's to say that '/' is a special
case however I think the behaviour described in (2) is the most consistent
as in all other cases in order not to lose path info we effectively treat a
registration as /{servlet-alias}/*. In effect I'd suggest we only use the
first of the mapping rules you listed from the servlet spec as the Http
Service doesn't have the concept of application scoping. The advantage of
this approach is that we can move a servlet's registration point around
safely without having to alter the servlet's implementation -- a situation
I've run into a number of times. On the flip side, I've yet to encounter a
servlet that took advantage of the default applicaton servlet behaviour.
-Simon
----- Original Message -----
From: "Alin Dreghiciu" <[EMAIL PROTECTED]>
To: "OSGi Alliance - General" <[email protected]>
Sent: Saturday, November 15, 2008 1:09 PM
Subject: [osgi-dev] Http Service: Mapping of "/" alias
Hi,
I have a question related to what do you guys think about the value
returned by HttpServletRequest getServletPath() and getPathInfo() in
case of an Http Service registered servlet with an alias of "/".
The problem appeared in Pax Web and was described like this:
"When a request of "/api/foo/bar" is made which matches to a servlet
registered at "/api" the servlet path is correctly set as "/api" and
the path info set to "/foo/bar". However if the same servlet is
registered in exactly the same manner to "/" and a request is made to
"/foo/bar" the servlet path is set to "/foo/bar" and the path info is
null. The servlet is somehow being treated as though it was mounted
against the exact uri that is being requested no matter what that uri
is."
Now, as Http Service specs down not mention anything about a relation
between the alias and servlet path and path info, I consider that http
service implementations should follow the servlet specs in this
matter. The servlet specs are as follow (this is from servlet specs
2.4):
SRV.11.2 Specification of Mappings
In theWeb application deployment descriptor, the following syntax is
used to define
mappings:
• A string beginning with a '/' character and ending with a '/*'
suffix is used for path mapping.
• A string beginning with a '*.' prefix is used as an extension mapping.
• A string containing only the '/' character indicates the "default"
servlet of the application. In this case the servlet path is the
request URI minus the context path and the path info is null.
• All other strings are used for exact matches only.
So, in the described bug above Pax Web acts accordingly to the servlet
specs.
So, what do you guys think: should a registration of "/" alias behave
as a servlet mapping of:
1) "/" - in this case for a request of "/foo/bar" the servlet path
will be "/foo/bar" and path info null
2) "/*" - in this case for a request of "/foo/bar" the servlet path
will be "" and path info "/foo/bar"
Some related resource (examples) can be found here:
http://jetty.mortbay.org/jetty5/faq/faq_s_500-Servlets_t_Path%20Mapping.html
Thanx,
--
Alin Dreghiciu
http://www.ops4j.org - New Energy for OSS Communities - Open
Participation Software.
http://www.qi4j.org - New Energy for Java - Domain Driven
Development.
http://malaysia.jayway.net - New Energy for Projects - Great People
working on Great Projects at Great Places
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev