Struts 1 or 2

sandeep1984
sandeep1984 used Ask the Experts™
on
Hi,

In my present I am using struts 1.2 and it works fine.
For my next project I am planning to use struts 2.

Is there any major advantages with struts 2?

What are the pros and cons.

Is there any plug ins for eclipse Ganymede/Galileo?

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Apache offers a nice table view comparing Struts 1 and 2:
http://struts.apache.org/2.1.6/docs/comparing-struts-1-and-2.html

We plan to use Struts 2 for our next project, but stay with Struts 1 for the current and not migrate it (at least not in the near future).

Again at Apache you can find a list of tools, including some for Eclipse:
http://wiki.apache.org/struts/StrutsTools

But for us, the "normal" WebToolsProject-Plugins are sufficient.

Author

Commented:
In Struts 1.2, I was using struts tokens for avoiding resubmission of a form using following mwthods

isTokenValid(request)
resetToken(request);
saveToken(request);

How can I do the same using Struts 2.
Top Expert 2009
Commented:
>>Is there any major advantages with struts 2?

Yes.

1) Better integration with newer frameworks and technologies. AJAX is one good example, struts2 has an easy drop-in for JSON serialization and you can write AJAX methods in a snap.
2) Ongoing maintennance, struts1 is really a deprecated framework that we all maintain but want to get away from.
3) Less config. You can do away with more of the configuration and use convention, like using the Struts2 wildcard mapping for actions, so there is no config entry required for each and every action and form. Actually you can do without form config altogether if you want.
4) Less code. The action is the class is the form. :) Simple POJO and you just write your getters and setters, no dynaform mapping or param.get()s required.
5) Nice pluggable architecture, you can override the "stack" easily with a config file and use some of the optional interceptors to do some neat stuff.

>>What are the pros and cons.

I understand the templates have a bit more overhead due to the freemarker interpreter, but I also know from one of the core Struts2 developers that it is being resolved by a rewritten template engine.

Overall I find Struts2/Webwork projects are TWICE as productive as S1 projects. Way less junk to maintain.

>>Is there any plug ins for eclipse Ganymede/Galileo?

Not sure, but I don't use them. S2 is so easy to work with once you get the hang of it, I feel no need for a plugin.

Good luck.

Author

Commented:
Thanks for the help.

I have an authentication filter to check whether user has logged in.
I have attached my filter mappings below.

It works fine with JSP files (all JSPs will be redirected to this filter), but not working with action (.action) clases. (Not being redirected to filter)

I need help on this regard.

Thanks.



	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
 
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
 
	<filter>
		<filter-name>AuthenticationFilter</filter-name>
		<filter-class>com.san.util.AuthFilter</filter-class>
		<init-param>
			<param-name>onFailure</param-name>
			<param-value>/login.jsp</param-value>
		</init-param>
		<init-param>
			<param-name>Login</param-name>
			<param-value>/login.action</param-value>
		</init-param>
		<init-param>
			<param-name>images</param-name>
			<param-value>/images</param-value>
		</init-param>
		<init-param>
			<param-name>script</param-name>
			<param-value>/script</param-value>
		</init-param>
	</filter>
 
	<filter-mapping>
		<filter-name>AuthenticationFilter</filter-name>
		<url-pattern>*.jsp</url-pattern>
	</filter-mapping>
 
	<filter-mapping>
		<filter-name>AuthenticationFilter</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>

Open in new window

Top Expert 2009

Commented:
That really should be a new question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial