This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Struts and the fly likes Infinite loop using LookupDispatchAction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Infinite loop using LookupDispatchAction" Watch "Infinite loop using LookupDispatchAction" New topic

Infinite loop using LookupDispatchAction

Ben Hagadorn

Joined: Mar 28, 2006
Posts: 25
I have a JSP page that allows the user to modify some data and then save it. After the data is saved I want to refresh the page. The problem that I'm having is that when the page is refreshed after the save, it fires the SAVE method again (and on into an infinite loop).

The action behind my page is a LookupDispatchAction with a mapped SAVE method and an UNSPECIFIED method to catch all unmapped actions. When the page is displayed for the first time I enter through the UNSPECIFIED method and retrieve data from the DB to display to the user. When the user selects the save button the code executes the mapped SAVE method and then attempts to refresh the page by forwarding the user back to the same page. I thought that I would re-enter the page through the UNSPECIFIED method (as I did the fist time the page was displayed) but I end up back in the SAVE again (and again, and again....). I need a way to refresh this page without coming back into the save method.

Any ideas? Is there something that needs to be cleared out after the first SAVE method has completed?

Thanks for the help.
Ben Hagadorn

Joined: Mar 28, 2006
Posts: 25
I got it. I needed to add redirect="true" to my struts.config file
I agree. Here's the link:
subject: Infinite loop using LookupDispatchAction
It's not a secret anymore!