[Jersey] Basic resource locator question

From: NBW <>
Date: Mon, 11 Apr 2011 13:58:44 -0400

Say I have two methods in a root resource like so:

public Response deleteById(@QueryParam("id") final long id) {

public Response deleteByLength(@QueryParam("length") final long length {

I would have thought that Jersey would see these as different resources but
it doesn't. It seems to see them as conflicting due to the fact they produce
the same media type. At least that is the error message that is logged. I
am guessing this goes beyond simply the same media type being produced but
also the fact that the type of the parameter is the same in both? I would
have expected Jersey to distinguish between them using the QueryParam name
as well, not just its type and see these as different resources.

Would then it mean that in this case I would need to use one method and test
to see how the parameters are set? eg. pseudo code:

public Response deleteByIdOrLength(@QueryParam("id") @DefaultValue("-1")
final long id,

@QueryParam("length") @DefaultValue("-1") final long length {
   if ((id == length == -1) || (id != -1 && length != -1))
      set appropriate error response
   else (if id != -1)
      set appropriate success response
      set appropriate success reponse
  return response

That seems rather ugly. Is there a better approach? Thnx,