Search code examples
javajerseylocalejax-rs

Getting the client locale in a jersey request


What is the best and more portable way to get the client locale in the context of a Jersey (JAX-RS) request? I have the following code:

@GET
@Produces("text/html")
@Path("/myrequest")
public Response myRequest(@Context HttpServletRequest request) {
    Locale locale = ...
}

Please assume that the "request" is made by some javascript code within a browser, by calling window.location = ...;


Solution

  • Locale locale = request.getLocale();