chkal / mvc-spec-migration-test

0 stars 0 forks source link

How does an MVC 1.0 @Controller handle a REDIRECT or FORWARD? #41

Closed chkal closed 9 years ago

chkal commented 9 years ago

Original issue MVC_SPEC-41 created by peter_pilgrim:

How does a MVC 1.0 @Controller handle a REDIRECT or a FORWARD?

In traditional, Java Servlet API it is possible to send a HTTP REDIRECT to the user client and it also possible to FORWARD to another Servlet instance in the same web application.

I think adding a REDIRECT property to the javax.mvc.Viewable will solve the former.

I am not sure how it work with JAX-RS in the FORWARD, possibly because this avenue of forwarding may not exist (yet).

chkal commented 9 years ago

Comment by Santiago Pericas-Geertsen:

Please see: https://java.net/jira/browse/MVC_SPEC-23

chkal commented 9 years ago

Comment by peter_pilgrim:

So how does one FORWARD then? Or does MVC 1.0 not intend to support FORWARD ?

chkal commented 9 years ago

Comment by peter_pilgrim:

Also REDIRECT requires the equivalent of the JSF @ViewScope for these beans. I think @ViewScope applied the javax.mvc.Models

chkal commented 9 years ago

Comment by Santiago Pericas-Geertsen:

Peter: Could you send questions to the users' alias instead? Short answer, yes there will be forward and a scope for redirecting. It's in the works.

chkal commented 9 years ago

Comment by Manfred Riem:

Peter, ViewScoped and Flash are not on the table as they are completely tied in with the JSF lifecycle. For MVC we are exploring a more narrow definition of a scope that will get 'similar' functionality upon redirect.

chkal commented 9 years ago

Comment by peter_pilgrim:

Yes I gathered that.

JAX-RS 2.1 only has Response#setTemporaryURI that looks close to ServletRequest.redirect but is not the cigar!

Perhaps this has to be solved with CDI integration and the MVC reference implementation. I think the @Inject Models models being attached the Servlet request scope is not good enough. So the MVC RI should provide something.

In particular, for application you have to be able to navigate outside of the @ApplicationPath() relative URI or whatever is set inside the web.xml e.g. "/rest/" or "/gateway" in to order redirect to pages effectively.

I tried the return new Viewable("redirect:/product.jsp"), but this not work in my experiments. I ended up with http://localhost:8080/acme/rest/product.jsp and not the expected http://localhost:8080/acme/product.jsp.

HTH