Eqbal
Eqbal

Reputation: 4880

Spring redirecting back to referrer

I have some resources in my application that require redirection to another resource (form) if some context information is not set. After the context gets set (requires two user steps), I need to redirect back to the requested resource. How do I achieve that. I am using annotation based controllers in Spring 3. Is org.springframework.security.web.savedrequest.HttpSessionRequestCache of any use.

Upvotes: 1

Views: 2036

Answers (2)

Bozho
Bozho

Reputation: 597204

Pass the location of the resource along on each page, as a hidden field.

Using the session to store it has one major drawback - if the user opens two tabs with different resources, one will be lost.

Upvotes: 0

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299038

you can of course do that kind of logic yourself in your controllers. Register a custom sesssion object, query the session object for an object that must be there in order to fulfill the condition. If the condition is fulfilled, show view a, otherwise show view b.

this kind of behavior will normally reside in an aspect of some sort, e.g. in a servlet interceptor

But I believe the best solution would be to use spring web flow http://www.springsource.org/webflow (although I have not tried it yet)

Upvotes: 1

Related Questions