Skip to main content



      Home
Home » Eclipse Projects » Equinox » ProxyServlet finds registered servlet for invalid url!?
ProxyServlet finds registered servlet for invalid url!? [message #88590] Tue, 22 May 2007 07:53 Go to next message
Eclipse UserFriend
Hi Simon,

(me again :)), I registered a servlet to the HttpService with the alias,
say "foo". Now, when I write "http://localhost:8080/mycontext/foo", as
exptected, my servlet gets initialized correctly and all works fine.
But when I add a "/" or an invalid path at the end of the url, the request
should result in a HTTP 404 error (that's the way, tomcat handles such
invalid url's).

However, the ProxyServlet finds my registered servlet for the path-info
"foo/", since the processAlias()-method just looks for the mapped alias,
which it finds in the "/"-seperated path and then delegates the request to
my own servlet.
Is there any reason, why my own servlet should deal with such invalid
requests?
I solved this problem, by parsing the path-info in the
handleSecurity()-method of my own HttpContext and processing invalid paths
with a 404 error (dirty), - I think, that should be something for the
ProxyServlet!?

- teos
Re: ProxyServlet finds registered servlet for invalid url!? [message #88620 is a reply to message #88590] Tue, 22 May 2007 13:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Teos,

Despite being "/" terminated the request is still a valid URL.
There are lots of cases where we really do want to handle requests that are
'/' terminated or otherwise want to interpret path_info.

The mapping rules for the OSGi HttpService are slightly different than those
used in web.xml and matching is done by longest prefix so "/foo" is in some
senses treated like " /foo/*". In your case where you don't want to treat
the request as valid you're doing the right thing as your servlet has to
handle it or potentially ignore it.

You've used a custom HttpContext in your case however if you're trying to
avoid adding aditional logic another approach you might consider is wrapping
your real Servlet in another that looks after the path_info parsing and
returns a 404 (or other code) for what your application does not want to
handle.
That said your approach valid and it's really up to you.

-Simon

"teos" <sasa.teofanovic@gmx.at> wrote in message
news:1471dbdd8023b2891ebbfde9ff9b1607$1@www.eclipse.org...
> Hi Simon,
>
> (me again :)), I registered a servlet to the HttpService with the alias,
> say "foo". Now, when I write "http://localhost:8080/mycontext/foo", as
> exptected, my servlet gets initialized correctly and all works fine. But
> when I add a "/" or an invalid path at the end of the url, the request
> should result in a HTTP 404 error (that's the way, tomcat handles such
> invalid url's).
>
> However, the ProxyServlet finds my registered servlet for the path-info
> "foo/", since the processAlias()-method just looks for the mapped alias,
> which it finds in the "/"-seperated path and then delegates the request to
> my own servlet.
> Is there any reason, why my own servlet should deal with such invalid
> requests?
> I solved this problem, by parsing the path-info in the
> handleSecurity()-method of my own HttpContext and processing invalid paths
> with a 404 error (dirty), - I think, that should be something for the
> ProxyServlet!?
>
> - teos
>
Re: ProxyServlet finds registered servlet for invalid url!? [message #88635 is a reply to message #88620] Wed, 23 May 2007 05:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Simon,

just for curiosity. Why does HttpService not work as web.xml where /foo
only does a strict matching and in cases where you also want
/foo/something* to match your servlet you would register the alias '/foo/*'?

regards
christian campo

Simon Kaegi schrieb:
> Hi Teos,
>
> Despite being "/" terminated the request is still a valid URL.
> There are lots of cases where we really do want to handle requests that are
> '/' terminated or otherwise want to interpret path_info.
>
> The mapping rules for the OSGi HttpService are slightly different than those
> used in web.xml and matching is done by longest prefix so "/foo" is in some
> senses treated like " /foo/*". In your case where you don't want to treat
> the request as valid you're doing the right thing as your servlet has to
> handle it or potentially ignore it.
>
> You've used a custom HttpContext in your case however if you're trying to
> avoid adding aditional logic another approach you might consider is wrapping
> your real Servlet in another that looks after the path_info parsing and
> returns a 404 (or other code) for what your application does not want to
> handle.
> That said your approach valid and it's really up to you.
>
> -Simon
>
> "teos" <sasa.teofanovic@gmx.at> wrote in message
> news:1471dbdd8023b2891ebbfde9ff9b1607$1@www.eclipse.org...
>> Hi Simon,
>>
>> (me again :)), I registered a servlet to the HttpService with the alias,
>> say "foo". Now, when I write "http://localhost:8080/mycontext/foo", as
>> exptected, my servlet gets initialized correctly and all works fine. But
>> when I add a "/" or an invalid path at the end of the url, the request
>> should result in a HTTP 404 error (that's the way, tomcat handles such
>> invalid url's).
>>
>> However, the ProxyServlet finds my registered servlet for the path-info
>> "foo/", since the processAlias()-method just looks for the mapped alias,
>> which it finds in the "/"-seperated path and then delegates the request to
>> my own servlet.
>> Is there any reason, why my own servlet should deal with such invalid
>> requests?
>> I solved this problem, by parsing the path-info in the
>> handleSecurity()-method of my own HttpContext and processing invalid paths
>> with a 404 error (dirty), - I think, that should be something for the
>> ProxyServlet!?
>>
>> - teos
>>
>
>
>
Re: ProxyServlet finds registered servlet for invalid url!? [message #88681 is a reply to message #88635] Wed, 23 May 2007 10:32 Go to previous message
Eclipse UserFriend
The HttpService was originally created in the Servlet 2.1 time frame which
predated standardization of web.xml's mapping semantics.
I invite you to take a look at the advanced mapping err... suggestions in
the Servlet 2.1 spec (page 14). :)
http://java.sun.com/products/servlet/2.1/servlet-2.1.pdf

-Simon

"Christian Campo" <christian.campo@compeople.de> wrote in message
news:f3127h$cpj$1@build.eclipse.org...
> Hi Simon,
>
> just for curiosity. Why does HttpService not work as web.xml where /foo
> only does a strict matching and in cases where you also want
> /foo/something* to match your servlet you would register the alias
> '/foo/*'?
>
> regards
> christian campo
>
> Simon Kaegi schrieb:
>> Hi Teos,
>>
>> Despite being "/" terminated the request is still a valid URL.
>> There are lots of cases where we really do want to handle requests that
>> are
>> '/' terminated or otherwise want to interpret path_info.
>>
>> The mapping rules for the OSGi HttpService are slightly different than
>> those
>> used in web.xml and matching is done by longest prefix so "/foo" is in
>> some
>> senses treated like " /foo/*". In your case where you don't want to treat
>> the request as valid you're doing the right thing as your servlet has to
>> handle it or potentially ignore it.
>>
>> You've used a custom HttpContext in your case however if you're trying to
>> avoid adding aditional logic another approach you might consider is
>> wrapping your real Servlet in another that looks after the path_info
>> parsing and returns a 404 (or other code) for what your application does
>> not want to handle.
>> That said your approach valid and it's really up to you.
>>
>> -Simon
>>
>> "teos" <sasa.teofanovic@gmx.at> wrote in message
>> news:1471dbdd8023b2891ebbfde9ff9b1607$1@www.eclipse.org...
>>> Hi Simon,
>>>
>>> (me again :)), I registered a servlet to the HttpService with the alias,
>>> say "foo". Now, when I write "http://localhost:8080/mycontext/foo", as
>>> exptected, my servlet gets initialized correctly and all works fine. But
>>> when I add a "/" or an invalid path at the end of the url, the request
>>> should result in a HTTP 404 error (that's the way, tomcat handles such
>>> invalid url's).
>>>
>>> However, the ProxyServlet finds my registered servlet for the path-info
>>> "foo/", since the processAlias()-method just looks for the mapped alias,
>>> which it finds in the "/"-seperated path and then delegates the request
>>> to
>>> my own servlet.
>>> Is there any reason, why my own servlet should deal with such invalid
>>> requests?
>>> I solved this problem, by parsing the path-info in the
>>> handleSecurity()-method of my own HttpContext and processing invalid
>>> paths
>>> with a 404 error (dirty), - I think, that should be something for the
>>> ProxyServlet!?
>>>
>>> - teos
>>>
>>
>>
Previous Topic:Starting the server
Next Topic:Possible to deduce plugin from object instance
Goto Forum:
  


Current Time: Thu May 08 21:13:50 EDT 2025

Powered by FUDForum. Page generated in 0.05360 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top