File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Redirect url in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Redirect url in struts" Watch "Redirect url in struts" New topic

Redirect url in struts

Sree Vidhya Ram

Joined: Sep 02, 2005
Posts: 3

Can any one clarify me the best way to redirect url in struts framework?

In the action bean we can use response.sendRedirect method to redirect to entirely different url.

This does violate to struts framework since we dont pass the control back to controller.

Instead if we do pass to controller and in the view layer say we use logic:redirect it does redirect to the required page.

Which is the best way or best practice to do?
What is the downside in each of the above ways?

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

The Controller gets no less control with a redirect than without one.

You can specify that a forward is a redirect in your struts-config.

A good workman is known by his tools.
Sree Vidhya Ram

Joined: Sep 02, 2005
Posts: 3
Thnks for your reply.
Yep I agree that the forward is a redirect in struts-config. That is how the struts framework speaks in the spec.

So can i presume that using sendRedirect in action bean does not violate the struts framework as the controller does not handle the task?
I agree. Here's the link:
subject: Redirect url in struts
It's not a secret anymore!