This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts 2 reditect to same URL 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 "Struts 2 reditect to same URL" Watch "Struts 2 reditect to same URL" New topic

Struts 2 reditect to same URL

Ramkumar Subburaj
Ranch Hand

Joined: Sep 07, 2007
Posts: 83

I am developing a web app using struts 2.

I have a module where the admin can add categories which are unique.

Assuming there are four categories - "bike","car","truck" and "bus".

Suppose the admin tries the to edit the category "bus" and tries to give the name "car" which already exists.

In that case, i want the user to redirect to the same url and show the error message.

is there any simple way in struts to redirect the user to the same URL from where the request came or i have to dynamically create the URL like "editCategory.action?catID=3"?

SCJP 1.5, SCWCD 1.4.
Hanging between Web Services and EJB
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 642
In your action declaration, just include an additional result element of type "input". In the action code, if you notice validation errors on the input values, just return Action.INPUT ("input") and the framework will forward to the input page.
I agree. Here's the link:
subject: Struts 2 reditect to same URL
Similar Threads
Possible to detect timeouts upon forwarding requests?
Clarification On TypeCasting of ArrayList in Java
how to redirect from prepare() method in struts 2
Struts 2 package name in Interceptor
Why abstract classes in java do not have objects, any strong reasons ?