Try Okta to add social login, MFA, and OpenID Connect support to your Java app in minutes. Create a free developer account today and never build auth again.

It’s easy to validate parameters in JAX-RS using filters – ContainerRequestFilter to be specific. There are other options at your disposal, e.g. using (CDI or EJB) interceptors, or injecting (HttpServletRequest using @Context)

Scenario: Validate Query Parameter Passed in by the Caller

Steps

Implement filter

Extracts query parameter from ContainerRequestContext

Performs the validation – aborts the request with an appropriate response status (and the error message)