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

Interceptor issue in Struts 2

Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96

I am writing a struts2 application, where I am using different workflows to understand different things. Currently, my index jsp has 2 forms, each associated with a separate action. One of them takes a name and prints the String "Hello+name" on the success page. The other one takes a name and a password, and if the values match a hard-coded pair of values, it shows a success page, else it reverts user back to the index page (I am testing interceptor for validation in this workflow). The struts.xml file is like this

Now, in the first action tag, I have not used any interceptor; yet the name gets transferred to my UserGreetingsPage.jsp automatically. Which means the params interceptor is called by default. In the second case..however, when I mentioned the workflow interceptor, I noticed that the params interceptor was not getting called automatically; because the values were not getting transferred.

My question is :
In Struts 2, the params interceptor will be called by default, but only if there is no mention of any other interceptor. If, however, any other interceptor is mentioned, then params also has to be called explicitly. Is my understanding correct?

OCJP 6.0
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

You have the right idea. By default the defaultStack is used. If you look at struts2 core jar you'll find a struts-default.xml where the defaultStack is defined, which is this:

Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96

Thanks Jesus, for helping me clear my doubt

I agree. Here's the link:
subject: Interceptor issue in Struts 2
jQuery in Action, 3rd edition