Hi,
What version of Jersey are you using?
If using Jersey 1.1.5 or greater if you can specify sever-side
preferences regardless of the what the client defines as most
acceptable. For example,
@GET
@Produces("application/xml;qs=2")
@Path("/{folderid: [a-zA-Z_0-9]|.*}")
public String getFolder(@PathParam("folderid") String folderId)
{
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{folderid: [a-zA-Z_0-9]|.*}")
public String getFolder(@PathParam("folderid") String folderId)
{
}
a default qs value is 1, the greater the qs value the higher the
preference.
So, for example if the client sends:
Accept: application/json, application/xml;q=0.8
the server will always return XML and not JSON, even though the client
prefers JSON over XML.
Paul.
On Mar 12, 2010, at 1:01 PM, emile wrote:
>
> Hi Pavel,
>
> I had messed up the regex; so now its working fine i.e. @Path("/
> {folderid:
> [a-zA-Z_0-9]|.*}").
>
> I have two methods(with the same URI), one producing a JSON and the
> other
> producing an XML. By default IE, picks JSON when i dont specify the
> extension. But after adding this regex, the method that is placed
> first in
> order is getting invoked. Not sure how to overcome this.
>
> @GET
> @Produces(MediaType.APPLICATION_XML)
> @Path("/{folderid: [a-zA-Z_0-9]|.*}")
> public String getFolder(@PathParam("folderid") String folderId)
> {
> }
>
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> @Path("/{folderid: [a-zA-Z_0-9]|.*}")
> public String getFolder(@PathParam("folderid") String folderId)
> {
> }
>
>
> --
> View this message in context: http://n2.nabble.com/Including-Folder-path-as-a-URI-variable-tp4716343p4721712.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>