users@jersey.java.net

[Jersey] Re: Best Way To Sanitize User Input

From: Martin Matula <martin.matula_at_oracle.com>
Date: Fri, 15 Jun 2012 21:51:30 +0200

Yes, this is possible. Implement ContainerRequestFilter, define an instance field annotated with @Context of type UriInfo (so that UriInfo is injected into it by Jersey runtime). Then in the filter method you can access UriInfo to get path and query parameters.
Form parameters can be obtained by calling ContainerRequest.getFormParameters() in the filter method - it returns empty form if no form parameters are in the request so you don't need to check for nulls.

You can join this list here: http://java.net/projects/jersey/lists

Regards,
Martin

On Jun 15, 2012, at 1:02 AM, dehru.cromer_at_emc.com wrote:

> Hello,
>
> I'm looking for the best way to sanitize user input. I'd love to be able to use the ContainerRequestFilter and loop through the form, path, and query parameters and sanitize them before they get passed into the handler methods. Is this possible? What's the recommended way to do this with Jersey?
>
> Thanks,
> Dehru
>
> P.S. How do I join this list?