Open chkal opened 9 years ago
Comment by Santiago Pericas-Geertsen:
Ozark implements redirect using the "redirect:" prefix. For example,
return "redirect:/foo";
which seems very convenient for controller methods returning strings.
Comment by peter_pilgrim:
Ok.
How do you get to the request.getContextPath() of your application then?
@POST
@Controller
@Path("edit/{id}")
@Produces("text/html")
public Viewable editProduct( @PathParam("id") int id,
@FormParam("action") String action,
@FormParam("name") String name,
@FormParam("description") String description,
@FormParam("price") double price )
{
if ("Save".equalsIgnoreCase(action)) {
/** ,,,**/
}
retrieveAll();
return new Viewable("redirect:/products.jsp");
}
}
The "redirect:/products.jsp" will alter the URI and still include the Application Path URI e.g.
http://localhost:8080/acme/gateway/product.jsp
This is probably not what the developer/designer wants. Instead they want
http://localhost:8080/acme/product.jsp
Assuming the "/acme" is the servlet context path
?
Comment by Santiago Pericas-Geertsen:
The relative path resolution is currently documented to be compatible with javax.ws.rs.core.Response#seeOther, which is also available to MVC controllers that return a Response.
Comment by Manfred Riem:
I think what he is saying what if you want to break out of the servlet path, but instead want to target the context path?
Original issue MVC_SPEC-23 created by Santiago Pericas-Geertsen:
JAX-RS 2.1 is likely to support a redirect call (just like servlet). This issue is recorded to track if whatever support is added to JAX-RS is sufficient for MVC.