Newsletter |
Struts 1.x vs Struts 2.x Main Differences
Struts » on Aug 17, 2011 { 61 Comments } By Sivateja
Let us see the component and functional differences between struts 1.x and struts 2.x
- In struts 1.x front controller is ActionServlet
- In 2.x front controller is FilterDispatcher
- In struts 1.x we have RequestProcessor class
- In 2.x we have Interceptors instead RequestProcessor will see about this concept later just remember as of now
- In struts 1.x we have multiple tag libraries like, html, logic, bean..etc
- In 2.x we do not have multiple libraries, instead we have single library which includes all tags
- In struts 1.x the configuration file name can be [any name].xml and we used to place in web-inf folder
- In 2.x the configuration file must be struts.xml only and this must be in classes folder
- In struts 1.x we have form beans and Action classes separately
- In 2.x form bean, Action classes are combinedly given as Action class only, of course we can take separately if we want 😉
- In struts 1.x properties file must be configured in struts-config.xml
- But in 2.x we need to configure our resource bundle(s) in struts.properties file
- In struts 1.x we have programmatic and declarative validations only
- In 2.x we have annotations support too along with programmatic and declarative validations
Functional Differences
- In struts 1.x declarative validations are done by using validation frame work
- In 2.x, declarative validations are done by using xwork2 frame work by webwork the reason being, its support valuations through Annotations
- In struts 1.x an Action class is a single ton class, so Action class object is not a thread safe, as a programmer we need to make it as thread safe by applying synchronization
- In 2.x an Action class object will be created for each request, so it is by default thread safe, so we no need to take care about safety issues here
- In struts 1.x we have only jsp as a view technology
- In 2.x we have support of multiple view technologies like velocity, Freemarker, jasper reports, jsp bla bla
- In struts 1.x Action class is having servlet dependency, because in execute() method accepts req, res parameter right ! so.
- In 2.x Action class doesn’t have any servlet dependency, because its execute() method doesn’t accepts any parameters, however we can access all servlet objects with dependency injection 🙂
You Might Also Like
::. About the Author .:: | ||
Comments
61 Responses to “Struts 1.x vs Struts 2.x Main Differences”
Hello. excellent job. I did not anticipate this. This is a fantastic story. Thanks!
Hiii,
Ultimate site….
@Herschel, @Harsh
Thank you friends…!!
Hi,fantastic site,as a beginner/professional its very much help full…an excellent job….super…super
@reddi prasad
Thanks much for your valuable feedback 🙂
Very useful site for java professionals. Great mentoring. Thanks for your valuable work.
@Karthik
you bet, thanks much.
this site is good..
Nice tutorial…
superb
its good.it is very usefull to freshers and professionals.
Thanks for your valuable work.
very good job…,very thanks it is very usefull to me
Thank you.Very nice…!
Thank you very much
These difference are very much help to get broader view in Struts.Thanks
its just awesome
its of gr8 help its awesome
greate help to me
thank you very much its very usefull to me.
great job.Can you please provide struts1.x tutorial
gud job …..like this
Very nice and easy to understand, helpful to many …
very much good tutorial for java beginner/professional . any one can easily understood . thanks to Java4s
clear explanation thanks ….. I like very much this site
very much helpful for the beginners, Detailed explanation about the topics, great site, keep going ..thanks
Wonderful job, a great concetp…. Thanks!
Really Very nice to learn 🙂 .Thanks a lot :):)
very very nice.every person can understand very easy for each topic.
Hi
Gud website clear the basic concepts………..
Very good explanation………. Thanks for your effort…
please upload strurs1x and junit
as soon as possible……….thanx in advanced
You have mentioned that
“In struts 1.x an Action class is a single ton class, so Action class object is not a thread safe, as a programmer we need to make it as thread safe by applying synchronization.”
Can anyone clear this line. ActionServlet is thread safe. Are you saying Action class is not thread safe?
Its very good.
nice post much appreciated…. 🙂
very clear explanation, thanks
really nice. now i got some idea between struts 1 and 2..thanks
its very nice site thanks
good….thanx
nice job bro
Hi,fantastic site,as a beginner/professional its very much help full…an excellent job….super…super
its really very helpful.. i like this site..excellent work…awesome
Very usful. thanks very much
awesome tutorial… Thanks Java4s Team……
It’s very nice site!!!!!!!
really helpful sites……..
very nice
Thanks…
Very very useful for me
very good explanation, sir. thanks!
Wow its very good. Its very helpful.
Thank you again!
Thank you Boss. I found one spelling mistake in this post. In this 7th line or point, you misspelled “file” as “fine”.
Excellent Sir Very Usefull
very useful site, content are very good.
Hi Anna…
please provide Struts 1 framework,It is an outdated technology but we have to use only structs 1 frame work for my project.
Plz give me some URLS’s or different types of examples on structs 1.
My Email : prakashy944@gmail.com
Thanks & Regards
very good tutorial..excellent work.
fabulous platform to learn Java. Thank you so much sir.!!!
Thank you sir your site is a best site.
very good differences. But need to add on number of instances created for action classes in struts1.2 and struts2.0
seriously very gud differences
in struts2.x its execute() method does not take any parameter, can we make execute() method that takes parameter.
Nice work sir..!
superb explanation which i never seen previous sites…..