users@jersey.java.net

Re: [Jersey] Using the _at_Head method when a corresponding _at_GET method is defined with same resource URL

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 01 Jun 2009 14:16:45 -0700

Hi,

I think this is related to issue 244:

https://jersey.dev.java.net/issues/show_bug.cgi?id=244

Could you add details to that issue?

Thanks,
Paul.

On Jun 1, 2009, at 2:01 PM, Jalpesh Patadia wrote:

> Hello,
>
> I went through the spec, and think this scenario should be
> supported. Basically in my resource class, I have the following
> definition:
>
> @Path(“/jsr311”)
> public class MyResource() {
> @HEAD
> @Path("{receipt}")
> public void isActiveOrder(….) throws ParseException
> {
> // standard head request stuff….
> }
>
> @GET
> @Path("{receipt}")
> @Produces( { "application/xml", "application/json", "text/csv" })
> public OrderData[] getOrderByReceipt(….) throws ParseException
> {
> // get the order data.
> }
> }
>
> So the isActiveOrder method should be called for an active order,
> while getOrderByReceipt should be called for an GET request. What
> I’m seeing is that the latter (getOrderByReceipt) is being called in
> both the cases, with the exception that when it’s being called with
> the HEAD call, it returns a 200.
>
> Interestingly, if I remove the @Produces(….) annotation in the
> getOrderByReceipt() method, things work fine and the isActiveOrder
> is called for the head request; and upon successful return I get a
> 204 (NO CONTENT) from the server. I can fix this by changing the
> @Path annotation for either one of my methods, but I prefer to keep
> the same URL for my resource (since it ties closely with the REST
> style)
>
>
> I just wanted to confirm if this is a known defect or not. I have
> tried 1.0.3 and 1.1.0-ea and both exhibit the same behavior.
>
>
> Note that I do not have an “Accept” header defined in my request, so
> I am using the defaults assumed by the container.
>
>
> Thanks,
>
>
> Jalpesh
>
> PRIVILEGED AND CONFIDENTIAL
> This transmission may contain privileged, proprietary or
> confidential information. If you are not the intended recipient, you
> are instructed not to review this transmission. If you are not the
> intended recipient, please notify the sender that you received this
> message and delete this transmission from your system.