dev@jersey.java.net

Re: ServletAdaptor mapping url-pattern

From: Nam Nguyen <Nam.Nguyen_at_Sun.COM>
Date: Wed, 18 Jul 2007 09:42:19 -0700

Paul Sandoz wrote:
> Hi Nam,
>
> Nam Nguyen wrote:
>> Hi,
>>
>> Currently tool generates a fixed (non-configurable) value:
>
> When you say 'tool' do you mean the NetBeans tool or the Jersey
> WebResourcesProcessorTask tool?
I means NB REST tool.
>
> The latter tool is configurable, for example use the following:
>
> <option key="urlpattern" value="/*"/>
>
> to generate in the web.xml the following:
>
> <servlet-mapping>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
Thanks, will try.
>
>
>> for this servlet-mapping/url-pattern:
>>
>> <url-pattern>/restbeans/*</url-pattern> (we will change this
>> to '/resources/*' matching the new jersey SimpleServlet sample)
>>
>> The effect is that RESTful application's URL space has to include
>> "restbeans", e.g.:
>>
>> http://www.acme.com/BookStore/restbeans/books/12345
>>
>> This is kind of undesirable compared with just:
>>
>> http://www.acme.com/BookStore/books/12345
>>
>
> I agree that this can be a problem.
>
>
>> We wonder if we could just use:
>> <url-pattern>/*</url-pattern>
>> so the latter URL is possible.
>>
>
> The issue i have with making the default URL pattern be '/*' is that
> the servlet adapter will currently consume all URLs including those
> for any content in the Web pages (HTML or JSPs etc), and so will
> return 404 (Not Found) for existing Web pages. You can verify this for
> yourself by playing around with the SimpleServlet example.
>
>
> Two possible solutions are:
>
> 1) The servlet adapter forward any URLs it does not know about. I
> think this can be done but there still could be clashes between URLs
> consumed by the resources and URLs that refer to content in the Web
> pages, which may not be an issue. I need to look into this further to
> see if this is something that should be specified by 311 servlet
> support or not.
This would be great because JSR implementation would be transparent to
REST application URL design.
>
> 2) The NetBeans tool allows the developer to select the base URL of the
> resources.
>
> and perhaps 2 is desirable even if 1 is supported?
The base URL customization is already possible with current web
application support in NB. I think we want to avoid introducing another
input parameter / question that users have to think about.

-Nam