Sunday, November 24, 2019

10 Departure Betwixt Struts In Addition To Struts2 Framework Inward Java

What is the divergence betwixt Struts 1 in addition to Struts ii is 1 of the pop Struts interview questions from Java JEE interviews? If you lot convey mentioned Struts inwards your CV so you lot tin await this inquiry on the telephonic or face-to-face circular of interview. Struts 1.x was a really pop MVC framework for Java spider web application on final decade, but when Spring MVC comes it lost a lot of its sheen. Spring framework's dependency injection in addition to inversion of control feature, along alongside several other template based features makes it the de-facto framework for developing Java application. But, the demand of Struts was non completely gone, at that topographic point are soundless a lot of company application written inwards Struts which needs Java developer alongside cognition of Struts to keep in addition to railroad train them, so it's 1 of the practiced science to acquire a Java spider web developer job. Apache than comes alongside Struts 2, the novel version of Struts which supports dependency injection in addition to several other features. In this article, I'll demonstrate you lot roughly key divergence betwixt Struts 1 in addition to Struts ii from interview indicate of view, but if you lot are learning Struts ii past times yourself in addition to looking for a practiced mass than purchase Struts ii inwards Action, 1 of the best books to acquire Struts 2.



Difference betwixt Struts 1.x vs Struts 2.x framework

Struts2 is designed to overcome the shortcomings of Struts1 in addition to to arrive to a greater extent than flexible, extendable. Some of the noticeable differences are:

Front Controller
One of the key structural In Struts 1.x ActionServlet acts equally a forepart controller in addition to for each request, a novel shape edible bean illustration is created to check parameter that is accessed past times Action class, land inwards Struts 2.x FilterDispatcher acts equally a forepart controller. As asking received a novel illustration of activity shape is created in addition to param interceptor charge all the parameter from the asking to the plain of activity instance.


Action Classes
Another telephone substitution divergence betwixt Struts 1.x in addition to Struts ii framework is that Struts1's Action classes are forced to extend an abstract class that makes it non extendable. Struts2's activity classes are to a greater extent than flexible in addition to nosotros tin create them past times implementing Action interface, extending ActionSupport shape or only past times having executed() method.



Thread Safety 
This is roughly other of import divergence betwixt Struts 1 in addition to Struts ii which is frequently overlooked past times Java developers. Struts1 Action Classes were Singleton in addition to non thread safe, that way extra attention was required from developer side to avoid whatever side effects because of multithreading. Struts2' activity classes acquire instantiated per request, so at that topographic point is no sharing in addition to multithreading, so they are thread safe.


Servlet API coupling
One of the bigger in addition to framework marking divergence betwixt Struts 1 in addition to Struts ii is that Struts 1 APIs are tightly coupled alongside Servlet API in addition to Request in addition to Response objects are passed to activity classes' execute() method. On the other hand, Struts2 API is loosely coupled alongside Servlet API in addition to automatically maps the shape edible bean information to activity shape coffee edible bean properties that nosotros generally use. If withal nosotros yell for a reference to Servlet API classes, at that topographic point are *Aware interfaces for that.


Testing 
This divergence is 1 of the most crucial divergence equally long equally code character in addition to productivity is a concern. Struts1 activity classes were difficult to bear witness because of Servlet API coupling, but Struts2 Action classes are similar normal Java classes in addition to nosotros tin bear witness them easily past times instantiating them in addition to setting their properties.


Request Parameters mapping
One to a greater extent than interesting divergence betwixt Struts 1 in addition to Struts ii is that Struts1 requires us to create ActionForm classes to check asking params in addition to nosotros yell for to configure it inwards the struts configuration file. Struts2 asking params mapping is done on the wing in addition to all nosotros yell for is to convey coffee edible bean properties inwards activity classes or implement ModelDriven interface to render the coffee edible bean shape yell to survive used for mapping.


Tag Support
Another functional divergence betwixt Struts 1 in addition to Struts ii is that Struts1 uses JSTL Tags in addition to so are limited. Struts2 uses OGNL in addition to render unlike kinds of UI, Control in addition to Data Tags. It’s to a greater extent than versatile in addition to slow to use.


Validation
One to a greater extent than useful divergence betwixt Struts 2.x in addition to Struts 1.x is that Struts1 supports validation through manual validate() method Struts2 back upwards both manual validation besides equally Validation framework integration.


Views Rendering 
The ninth divergence betwixt Struts 1.x in addition to Struts 2.x version are that Struts1 uses measure JSP technology for providing edible bean values to JSP pages for views. Struts2 uses ValueStack to shop asking params in addition to attributes in addition to nosotros tin usage OGNL in addition to Struts2 tags to access them.


Modules support
Last but non the to the lowest degree divergence betwixt Struts 1.x in addition to Struts 2.x is that Struts1 modules are complex to pattern in addition to facial expression similar dissever projects Struts2 provides “namespace” configuration for packages to easily create modules.

So, these were 10 key divergence betwixt Struts 1.x in addition to Struts2.x spider web MVC framework. Here is a prissy summary of roughly to a greater extent than divergence betwixt Struts 1 in addition to Struts 2.x framework from Apache Struts website:
 If you lot convey mentioned Struts inwards your CV so you lot tin await this inquiry on the telephon 10 divergence betwixt Struts in addition to Struts2 framework inwards Java


That's all close the difference betwixt Struts in addition to Struts 2.0 spider web MVC framework inwards Java. Even though Struts ii seems an extension of Struts 1, it's a completely unlike spider web MVC framework. It's to a greater extent than similar to Spring MVC than Struts ii itself.

Other Sturts articles, tutorials in addition to interview questions you lot may like:
  • How to acquire ServletContext inwards Struts Action Class? (answer)
  • 10 examples of the display tag alongside Struts inwards Java? (article)
  • 3 Free Struts Books for Java Developers? (see here)
  • More differences betwixt Struts 1.x in addition to Struts 2.x inwards Java (answer)

Further Learning
Java Web Fundamentals By Kevin Jones
Struts ii Framework for Beginners
Spring Framework Master Class - Beginner to Expert

No comments:

Post a Comment