wood burning stoves 2.0*
The moose likes Struts and the fly likes Call a forward or a redirect inside an interceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Call a forward or a redirect inside an interceptor" Watch "Call a forward or a redirect inside an interceptor" New topic
Author

Call a forward or a redirect inside an interceptor

kalyan narra
Greenhorn

Joined: Sep 17, 2008
Posts: 10
Hello everybody,

Is there a way using the struts 2 API to forward or redirect to a url
inside an interceptor instead of making a actionInvocation.invoke()?

Any one please help me how to do this?

Thanks,
Kalyan G.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You *could* just do a forward or redirect. But if you're hitting something within your application it'd be much, much cleaner to just return a result name.
kalyan narra
Greenhorn

Joined: Sep 17, 2008
Posts: 10
Thanks for your reply David, Yes you are right but my interceptors not every time call the forward Action. Based on users request it should dynamically knows that is this request should be forward to action or it should be normal invoke..

currently i am return the invocation.invoke(); how can i do it dinamically?

Please let me know your thoughts for the same.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Return the name of a result? I don't really know what you're asking.
kalyan narra
Greenhorn

Joined: Sep 17, 2008
Posts: 10
What my requirement is that.. I have written one Interceptor and this works normally like for each and every request its get the data form session and check with DB and based on users request it should go to that particular action class and execute normally.

Currently what I am going to change this interceptor like in that session details matches with DB details then I need to directly forward that user to his account page.. if the session data not matches with DB then I will do the normal process same as above..

For this how can I do this dynamically? And in this interceptor I will get the user account path form db.. so I need to forward that user to his account path.

So could you please help me how can I forward action inside my interceptor?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What is "his account path"? Is it a path inside the application? An action? Does it require parameters? TellTheDetails.
kalyan narra
Greenhorn

Joined: Sep 17, 2008
Posts: 10
Yes is the path inside the application, and the path contains parameters also but i was get those parameters from the session. just i need to forward that path.. it look like "http://localhost:8080/test/ContractDetails.action?contract.contractId=188&contractId=188".

if the user is valid then i need to forwad to this action.

please help me how do i do it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call a forward or a redirect inside an interceptor
 
Similar Threads
what does redirect attribute of action forward do when set to false
Redirect to another action in Interceptor
Redirecting the req to another server ?
how to get the cookie value in strut2
servlet