It's not a secret anymore!*
The moose likes Struts and the fly likes redirect=true in config does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "redirect=true in config does not work" Watch "redirect=true in config does not work" New topic
Author

redirect=true in config does not work

Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
I've added redirect=true in something like <forward name="success" path="/newsletterok.do" redirect="true"/>, yet the page does not redirect. When i use then this works as intended. Why is that?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What behavior are you seeing?
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
Using the config file redirect, the user gets sent to the jsp yet the URL is pointing to the servlet. If i refresh i get a POST once again.
If i use the new ActionForward code, it works as intended. I see the new URL where i'm forwarding to as well as refreshing without posting data back to the server.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Gets sent to what JSP?
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
using the above example... the newsletterok.jsp page.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

What is the servlet *supposed* to display? I mean, if you redirect to a URL that's the URL that's going to be in the browser.
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
They go to the same place, but the problem is that using the config method it only forwards even if i set the redirect=true.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How do you know?
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
well the the difference is in the URL and on the refresh... If i do a refresh on a page that got "redirected" from the struts config, it tries to post back to the servlet... thus giving me the impression the page got forwarded rather than redirected. Am i wrong?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You wrote: Using the config file redirect, the user gets sent to the jsp yet the URL is pointing to the servlet. If i refresh i get a POST once again.
If the URL is of the servlet then it got redirected.

Not sure about the refresh thing, but I just find it *extremely* unlikely that redirect="true" doesn't work, as it's pretty much been working for 7-8 years.
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
Ok so better question. How can i tell the difference between a forward or redirect from the client side? I too find it odd, but maybe there is something that is overwritting that configuration file setting
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's also unlikely. Use something like Firebug or a local proxy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: redirect=true in config does not work