Take the 2-minute tour ×

i work on an application that uses Struts2 and Struts1. Now i want to implement authentication for different actions. I'd like to use an interceptor to check to which namespace an action belongs. I wrapped all Struts1 action with Struts2 action. So all strut1-action run through the interceptor.

<action name="contactsList" class="com.opensymphony.xwork2.ActionSupport">
    <result name="success">contactsList.do</result>

The problem is that if a user enters a struts1-action in the browser the interceptor will not be called.

My question: Is there a difference between action calls coming from the browser and action calls called via Struts configuration. If it is possible, is it possible to disallow Struts1 actions from the browser but from within struts it is allowed?

share|improve this question
Disable struts1 and only use the struts2 dispatcher? –  Boris the Spider Apr 11 '13 at 7:51
do you mean the servlet-mapping? <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> –  IonTichy Apr 11 '13 at 8:47
Yes, and the servlet itself. Then users will only be able to access content via the struts2 dispatcher. –  Boris the Spider Apr 11 '13 at 8:57
No, that doesn't work because then no struts1 action will be called. I want that the redirect from struts2 .action to struts1 .do should work but it should not work from an entered url. –  IonTichy Apr 11 '13 at 9:40
add comment

1 Answer

up vote 0 down vote accepted

You have thought in the wrong direction. There's a Struts1 plugin in Struts2 that actually wraps the Struts1 action. So, the code will look like

<action name="contactsList" class="org.apache.struts2.s1.Struts1Action">
  <param name="className">com.mycompany.myapp.ContactsListAction</param>

To your question the Struts2 return result that either redirect or dispatch to the servlet even if your action doing nothing. You could do anything with the browser but Struts will accept requests until you map it to the url where it's responsible to react on the browser requests.

share|improve this answer
The documentation says "The Struts 1 plugin is currently only intended to allow you to run Strust 1 actions inside a Struts 2 application. It DOES NOT allow you to continue to use the Struts 1 tag libraries in your JSPs. Your JSPs must be converted to use the Struts 2 tag library." I am not able to change the struts1 action nor the jsps. I have to use them like they are. –  IonTichy Apr 11 '13 at 12:06
That's right, this is the way to migration. You have either do it or use both frameworks together but not the way you did. –  Roman C Apr 11 '13 at 12:08
add comment

Your Answer


