aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Redirect url in struts" Watch "Redirect url in struts" New topic
Author

Redirect url in struts

Sree Vidhya Ram
Greenhorn

Joined: Sep 02, 2005
Posts: 3
Ranchers
Hi!

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?

Thanks!
Marc Peabody
pie sneak
Sheriff

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: Redirect url in struts
 
Similar Threads
This weeks giveaway : "JSP Examples and Best Practices".
Configuring Servlets in web.xml
MVC design pattern in the Client Server Architecture?
Design Patterns Front Controller vs Page Controller
JAR the web-application or use WSDL/SOA ?!?!