I am writing a prototype Jersey application (JAX-RS) and wanted to try processing the application messages / x -www-form-urlencoded with the redirect methodology after POST.
I want to redirect to the html page located in the root of the application to succeed, however I cannot escape from the root of the Jersey servlet.
Here is an example of a resource that allows you to create a new user:
URI I want: /jersey-test/user.html
URI I get: / jersey-test / r /user.html
@POST @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) public Response putUser(@Context UriInfo uriInfo, MultivaluedMap<String, String> formParams) { // snip... do work and insert user here... URI uri = uriInfo.getBaseUriBuilder().path("user.html").build(); return Response.seeOther(uri).build(); }
Relevant snippets from my web.xml:
<web-app ...> <display-name>jersey-test</display-name> ... <servlet> <servlet-name>Jersey REST Service</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> ... </servlet> ... <servlet-mapping> <servlet-name>Jersey REST Service</servlet-name> <url-pattern>/r/*</url-pattern> </servlet-mapping> </web-app>
source share