Get all updates of Java4s
Follow Us: Email Newsletter

Struts 1.x vs Struts 2.x Main Differences

Struts » On Aug 17, 2011 { 59 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 Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

59 Responses to “Struts 1.x vs Struts 2.x Main Differences”
  1. Herschel Clack says:

    Hello. excellent job. I did not anticipate this. This is a fantastic story. Thanks!

  2. Harsh says:

    Hiii,
    Ultimate site….

  3. java4s.com says:

    @Herschel, @Harsh
    Thank you friends…!!

  4. reddi prasad says:

    Hi,fantastic site,as a beginner/professional its very much help full…an excellent job….super…super

  5. Java4s says:

    @reddi prasad

    Thanks much for your valuable feedback :-)

  6. Karthik says:

    Very useful site for java professionals. Great mentoring. Thanks for your valuable work.

  7. Java4s says:

    @Karthik

    you bet, thanks much.

  8. prabakar says:

    this site is good..

  9. srini says:

    Nice tutorial…

  10. Koteswararao says:

    its good.it is very usefull to freshers and professionals.
    Thanks for your valuable work.

  11. Raju says:

    very good job…,very thanks it is very usefull to me

  12. Thank you.Very nice…!

  13. Anji says:

    Thank you very much

  14. Bhupathi says:

    These difference are very much help to get broader view in Struts.Thanks

  15. shashi says:

    its just awesome

  16. shashi says:

    its of gr8 help its awesome

  17. suresh says:

    greate help to me

  18. Ravindra says:

    thank you very much its very usefull to me.

  19. Amarnath says:

    great job.Can you please provide struts1.x tutorial

  20. gopal says:

    gud job …..like this

  21. Nagarjuna.k says:

    Very nice and easy to understand, helpful to many …

  22. Nayeem says:

    very much good tutorial for java beginner/professional . any one can easily understood . thanks to Java4s

  23. venkatesh says:

    clear explanation thanks ….. I like very much this site

  24. very much helpful for the beginners, Detailed explanation about the topics, great site, keep going ..thanks

  25. Mukesh Kumar says:

    Wonderful job, a great concetp…. Thanks!

  26. sobana says:

    Really Very nice to learn :) .Thanks a lot :):)

  27. very very nice.every person can understand very easy for each topic.

  28. Shweta says:

    Hi
    Gud website clear the basic concepts………..

  29. friend says:

    Very good explanation………. Thanks for your effort…

  30. tanmayameher says:

    please upload strurs1x and junit
    as soon as possible……….thanx in advanced

  31. Dharmendra says:

    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?

  32. naveen says:

    nice post much appreciated…. :)

  33. surya says:

    very clear explanation, thanks

  34. vignesh says:

    really nice. now i got some idea between struts 1 and 2..thanks

  35. saikrishna says:

    its very nice site thanks

  36. siva says:

    good….thanx

  37. parvez says:

    nice job bro

  38. Gopinadh says:

    Hi,fantastic site,as a beginner/professional its very much help full…an excellent job….super…super

  39. arpita says:

    its really very helpful.. i like this site..excellent work…awesome

  40. hari says:

    Very usful. thanks very much

  41. Jayul says:

    awesome tutorial… Thanks Java4s Team……

  42. It’s very nice site!!!!!!!

  43. jay pal says:

    really helpful sites……..

  44. UTTAM KUMAR says:

    Thanks…
    Very very useful for me

  45. Hariy says:

    very good explanation, sir. thanks!

  46. Sridhar says:

    Wow its very good. Its very helpful.
    Thank you again!

  47. anbhu says:

    Thank you Boss. I found one spelling mistake in this post. In this 7th line or point, you misspelled “file” as “fine”.

  48. shyam says:

    Excellent Sir Very Usefull

  49. vivek says:

    very useful site, content are very good.

  50. prakash says:

    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

  51. Abdul Raoof says:

    very good tutorial..excellent work.

  52. Rashmi says:

    fabulous platform to learn Java. Thank you so much sir.!!!

  53. shyam Sundar says:

    Thank you sir your site is a best site.

  54. Shahji Dhole says:

    very good differences. But need to add on number of instances created for action classes in struts1.2 and struts2.0

  55. Alpana says:

    seriously very gud differences

  56. ashwani says:

    in struts2.x its execute() method does not take any parameter, can we make execute() method that takes parameter.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.