Support for HTTP forward
Issue by mvcbot
Tuesday Jan 13, 2015 at 18:01 GMT
Originally opened as https://github.com/mvc-spec/mvc-spec/issues/35
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.
Comment by mvcbot
Friday Apr 17, 2015 at 12:49 GMT
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 mvcbot
Friday May 29, 2015 at 13:16 GMT
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 mvcbot
Friday Jul 31, 2015 at 14:43 GMT
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 mvcbot
Wednesday Aug 05, 2015 at 18:48 GMT
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?
Comment by chkal
Sunday Feb 11, 2018 at 13:00 GMT
I don't think it is worth to include this in 1.0. Any objections?