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 .::

Java4s_Author
Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

61 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. its good.it is very usefull to freshers and professionals.
    Thanks for your valuable work.

  9. Raju says:

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

  10. Thank you.Very nice…!

  11. Anji says:

    Thank you very much

  12. Bhupathi says:

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

  13. shashi says:

    its just awesome

  14. shashi says:

    its of gr8 help its awesome

  15. suresh says:

    greate help to me

  16. Ravindra says:

    thank you very much its very usefull to me.

  17. Amarnath says:

    great job.Can you please provide struts1.x tutorial

  18. gopal says:

    gud job …..like this

  19. Very nice and easy to understand, helpful to many …

  20. Nayeem says:

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

  21. venkatesh says:

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

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

  23. Wonderful job, a great concetp…. Thanks!

  24. sobana says:

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

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

  26. Shweta says:

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

  27. friend says:

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

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

  29. 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?

  30. naveen says:

    nice post much appreciated…. 🙂

  31. surya says:

    very clear explanation, thanks

  32. vignesh says:

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

  33. saikrishna says:

    its very nice site thanks

  34. siva says:

    good….thanx

  35. parvez says:

    nice job bro

  36. Gopinadh says:

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

  37. arpita says:

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

  38. hari says:

    Very usful. thanks very much

  39. Jayul says:

    awesome tutorial… Thanks Java4s Team……

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

  41. jay pal says:

    really helpful sites……..

  42. UTTAM KUMAR says:

    Thanks…
    Very very useful for me

  43. Hariy says:

    very good explanation, sir. thanks!

  44. Sridhar says:

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

  45. anbhu says:

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

  46. shyam says:

    Excellent Sir Very Usefull

  47. vivek says:

    very useful site, content are very good.

  48. 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

  49. Abdul Raoof says:

    very good tutorial..excellent work.

  50. Rashmi says:

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

  51. Thank you sir your site is a best site.

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

  53. Alpana says:

    seriously very gud differences

  54. ashwani says:

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

  55. warish says:

    Nice work sir..!

  56. Harinath Reddy says:

    superb explanation which i never seen previous sites…..

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

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