users@glassfish.java.net

Re: Wildcard URL matching when using HTTPBinding

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Fri, 27 Apr 2007 18:06:06 -0700

glassfish_at_javadesktop.org wrote On 04/27/07 05:16 PM,:

>I've been looking through the Glassfish source for the deployment descriptors, and it doesn't appear that there is a way to customize the servlet-mapping when generating internal web.xml file.
>
>I am building a RESTful web service, and would prefer to use URL patterns instead of query string parameters. (ie, GET /rest/Product/1234 and not GET /rest?t=Product&pid=1234).
>
>So, I would like to be able to do have the web.xml mapping look more like:
>
> <servlet-mapping>
> <servlet-name>ApiREST</servlet-name>
> <url-pattern>/rest</url-pattern>
> </servlet-mapping>
> <servlet-mapping>
> <servlet-name>ApiREST</servlet-name>
>[b] <url-pattern>/rest/*</url-pattern>[/b]
> </servlet-mapping>
>
>Is there any way to do this in the annotations that I'm missing? Or do I need to deploy my own web.xml, webservices.xml, wsdl, etc and all the other stuff that goes with having to do that?
>
>

I may have misunderstood your question, but the Servlet spec already
supports path (prefix) mappings, which are specified using a string that
begins with a '/' character and ends with a "/*" suffix.

See SRV.11.2 ("Specification of Mappings") of the Servlet spec for details.

This means that:

  <servlet-mapping>
      <servlet-name>ApiREST</servlet-name>
      <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

is a valid servlet mapping.

But again, I may have misunderstood your question ...


Jan