users@jersey.java.net

QueryParam not injected

From: Anna Vagelin <anna.vagelin_at_tactel.se>
Date: Wed, 03 Jun 2009 12:45:33 +0200

Hi,

I'm trying Jersey in a Apache Tomcat solution where we used to run all
requests through Servlets. There is a filterchain with filters doing all
sorts of things e.g. adding parameters to the incoming request. When
injecting one of these additional parameters as @QueryParam into the
Resource, the parameter is null. However, if injecting the request via
@Context and then pulling the parameter from it the parameter is
instantiated correctly. How is this possible? What can I do to be able
to use the @QueryParam?

I'm using Jersey 1.0.

@GET
@Produces("*/xml")
public Response getXml(@QueryParam("resolution") @DefaultValue("not
defined") String resolution, @Context HttpServletRequest request) throws
IOException {

    if (resolution == "not defined") {
            System.out.println("Resolution not defined in parameter);
//Always printed
    }
    if (request != null) {
            System.out.println("Resolution from request" +
request.getParameter("resolution")); //Always printed correctly
    }

        return ...
 }

Best Regards

Anna Vagelin