What is the divergence betwixt Struts 1 as well as Struts two is i of the pop Struts interview questions from Java JEE interviews? If yous accept mentioned Struts inward your CV as well as then yous tin await this enquiry on the telephonic or face-to-face circular of interview. Struts 1.x was a real pop MVC framework for Java spider web application on terminal decade, but when Spring MVC comes it lost a lot of its sheen. Spring framework's dependency injection as well as inversion of control feature, along amongst 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 spot are soundless a lot of firm application written inward Struts which needs Java developer amongst noesis of Struts to hold as well as prepare them, so it's i of the practiced science to acquire a Java spider web developer job. Apache than comes amongst Struts 2, the novel version of Struts which supports dependency injection as well as several other features. In this article, I'll present yous to a greater extent than or less key divergence betwixt Struts 1 as well as Struts two from interview indicate of view, but if yous are learning Struts two past times yourself as well as looking for a practiced mass than purchase Struts two inward Action, i of the best books to larn Struts 2.
Front Controller
One of the key structural In Struts 1.x ActionServlet acts every bit a front end controller as well as for each request, a novel cast edible bean illustration is created to jibe parameter that is accessed past times Action class, piece inward Struts 2.x FilterDispatcher acts every bit a front end controller. As asking received a novel illustration of activity cast is created as well as param interceptor charge all the parameter from the asking to the plain of activity instance.
Action Classes
Another cardinal divergence betwixt Struts 1.x as well as Struts two 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 as well as nosotros tin create them past times implementing Action interface, extending ActionSupport cast or but past times having executed() method.
Thread Safety
This is to a greater extent than or less other of import divergence betwixt Struts 1 as well as Struts two which is oftentimes overlooked past times Java developers. Struts1 Action Classes were Singleton as well as non thread safe, that agency extra tending was required from developer side to avoid whatever side effects because of multithreading. Struts2' activity classes acquire instantiated per request, so at that spot is no sharing as well as multithreading, thence they are thread safe.
Servlet API coupling
One of the bigger as well as framework degree divergence betwixt Struts 1 as well as Struts two is that Struts 1 APIs are tightly coupled amongst Servlet API as well as Request as well as Response objects are passed to activity classes' execute() method. On the other hand, Struts2 API is loosely coupled amongst Servlet API as well as automatically maps the cast edible bean information to activity cast coffee edible bean properties that nosotros to a greater extent than oftentimes than non use. If all the same nosotros scream for a reference to Servlet API classes, at that spot are *Aware interfaces for that.
Testing
This divergence is i of the most crucial divergence every bit long every bit code character as well as productivity is a concern. Struts1 activity classes were difficult to examine because of Servlet API coupling, but Struts2 Action classes are similar normal Java classes as well as nosotros tin examine them easily past times instantiating them as well as setting their properties.
Request Parameters mapping
One to a greater extent than interesting divergence betwixt Struts 1 as well as Struts two is that Struts1 requires us to create ActionForm classes to jibe asking params as well as nosotros scream for to configure it inward the struts configuration file. Struts2 asking params mapping is done on the wing as well as all nosotros scream for is to accept coffee edible bean properties inward activity classes or implement ModelDriven interface to render the coffee edible bean cast scream to survive used for mapping.
Tag Support
Another functional divergence betwixt Struts 1 as well as Struts two is that Struts1 uses JSTL Tags as well as thence are limited. Struts2 uses OGNL as well as render dissimilar kinds of UI, Control as well as Data Tags. It’s to a greater extent than versatile as well as tardily to use.
Validation
One to a greater extent than useful divergence betwixt Struts 2.x as well as Struts 1.x is that Struts1 supports validation through manual validate() method Struts2 back upward both manual validation likewise every bit Validation framework integration.
Views Rendering
The ninth divergence betwixt Struts 1.x as well as Struts 2.x version are that Struts1 uses criterion JSP technology for providing edible bean values to JSP pages for views. Struts2 uses ValueStack to shop asking params as well as attributes as well as nosotros tin work OGNL as well as Struts2 tags to access them.
Modules support
Last but non the to the lowest degree divergence betwixt Struts 1.x as well as Struts 2.x is that Struts1 modules are complex to pattern as well as human face similar split projects Struts2 provides “namespace” configuration for packages to easily create modules.
So, these were 10 key divergence betwixt Struts 1.x as well as Struts2.x spider web MVC framework. Here is a overnice summary of to a greater extent than or less to a greater extent than divergence betwixt Struts 1 as well as Struts 2.x framework from Apache Struts website:
That's all virtually the difference betwixt Struts as well as Struts 2.0 spider web MVC framework inward Java. Even though Struts two seems an extension of Struts 1, it's a completely dissimilar spider web MVC framework. It's to a greater extent than similar to Spring MVC than Struts two itself.
Other Sturts articles, tutorials as well as interview questions yous may like:
Further Learning
Java Web Fundamentals By Kevin Jones
Introduction to Spring MVC
Struts two inward Action By Don Brown
Difference betwixt Struts 1.x vs Struts 2.x framework
Struts2 is designed to overcome the shortcomings of Struts1 as well as to acquire inward 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 every bit a front end controller as well as for each request, a novel cast edible bean illustration is created to jibe parameter that is accessed past times Action class, piece inward Struts 2.x FilterDispatcher acts every bit a front end controller. As asking received a novel illustration of activity cast is created as well as param interceptor charge all the parameter from the asking to the plain of activity instance.
Action Classes
Another cardinal divergence betwixt Struts 1.x as well as Struts two 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 as well as nosotros tin create them past times implementing Action interface, extending ActionSupport cast or but past times having executed() method.
Thread Safety
This is to a greater extent than or less other of import divergence betwixt Struts 1 as well as Struts two which is oftentimes overlooked past times Java developers. Struts1 Action Classes were Singleton as well as non thread safe, that agency extra tending was required from developer side to avoid whatever side effects because of multithreading. Struts2' activity classes acquire instantiated per request, so at that spot is no sharing as well as multithreading, thence they are thread safe.
Servlet API coupling
One of the bigger as well as framework degree divergence betwixt Struts 1 as well as Struts two is that Struts 1 APIs are tightly coupled amongst Servlet API as well as Request as well as Response objects are passed to activity classes' execute() method. On the other hand, Struts2 API is loosely coupled amongst Servlet API as well as automatically maps the cast edible bean information to activity cast coffee edible bean properties that nosotros to a greater extent than oftentimes than non use. If all the same nosotros scream for a reference to Servlet API classes, at that spot are *Aware interfaces for that.
Testing
This divergence is i of the most crucial divergence every bit long every bit code character as well as productivity is a concern. Struts1 activity classes were difficult to examine because of Servlet API coupling, but Struts2 Action classes are similar normal Java classes as well as nosotros tin examine them easily past times instantiating them as well as setting their properties.
Request Parameters mapping
One to a greater extent than interesting divergence betwixt Struts 1 as well as Struts two is that Struts1 requires us to create ActionForm classes to jibe asking params as well as nosotros scream for to configure it inward the struts configuration file. Struts2 asking params mapping is done on the wing as well as all nosotros scream for is to accept coffee edible bean properties inward activity classes or implement ModelDriven interface to render the coffee edible bean cast scream to survive used for mapping.
Tag Support
Another functional divergence betwixt Struts 1 as well as Struts two is that Struts1 uses JSTL Tags as well as thence are limited. Struts2 uses OGNL as well as render dissimilar kinds of UI, Control as well as Data Tags. It’s to a greater extent than versatile as well as tardily to use.
Validation
One to a greater extent than useful divergence betwixt Struts 2.x as well as Struts 1.x is that Struts1 supports validation through manual validate() method Struts2 back upward both manual validation likewise every bit Validation framework integration.
Views Rendering
The ninth divergence betwixt Struts 1.x as well as Struts 2.x version are that Struts1 uses criterion JSP technology for providing edible bean values to JSP pages for views. Struts2 uses ValueStack to shop asking params as well as attributes as well as nosotros tin work OGNL as well as Struts2 tags to access them.
Modules support
Last but non the to the lowest degree divergence betwixt Struts 1.x as well as Struts 2.x is that Struts1 modules are complex to pattern as well as human face similar split projects Struts2 provides “namespace” configuration for packages to easily create modules.
So, these were 10 key divergence betwixt Struts 1.x as well as Struts2.x spider web MVC framework. Here is a overnice summary of to a greater extent than or less to a greater extent than divergence betwixt Struts 1 as well as Struts 2.x framework from Apache Struts website:
That's all virtually the difference betwixt Struts as well as Struts 2.0 spider web MVC framework inward Java. Even though Struts two seems an extension of Struts 1, it's a completely dissimilar spider web MVC framework. It's to a greater extent than similar to Spring MVC than Struts two itself.
Other Sturts articles, tutorials as well as interview questions yous may like:
- How to acquire ServletContext inward Struts Action Class? (answer)
- 10 examples of the display tag amongst Struts inward Java? (article)
- 3 Free Struts Books for Java Developers? (see here)
- More differences betwixt Struts 1.x as well as Struts 2.x inward Java (answer)
Further Learning
Java Web Fundamentals By Kevin Jones
Introduction to Spring MVC
Struts two inward Action By Don Brown
0 Response to "10 departure betwixt Struts too Struts2 framework inward Java"
Posting Komentar