I would like to know the difference between Struts 1.x and Struts 2.x
Struts 1 supports separate Request Processors (lifecycles) for each module, but all the Actions in the module must share the same lifecycle. Struts 2 supports creating different lifecycles on a per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed.
The easiest approach to migration is to add the Struts 2 JAR file (available from the Apache Project; see Resources) to the application and migrate code on one page at a time. Many changes are just a matter of removing Struts 1 classes and tags that are not needed and including what is required for Struts 2.
A Servlet is a technology and Struts is a framework which relies on or makes use of Servlets.
The major difference is that in Struts1.x the request directly goes to the servlet, whereas in Struts2.x the request and response traval though the stack of interceptor or filter. The regular logic can be placed in Filter classes and developer can concentrate on the Business Logic. Besides this there is also differences in directory structure.
It is better to know the differences between Struts1.x and Struts2.x topic wise. Here's a cite of http://www.geekinterview.com/question_details/64360:
In Struts 1.x the action classes should extend Action (or DispatchAction) class and the execute method have number of parameter and a ActionForward return type , but In struts 2.x the action class can also be simple pojo having execute method returning only a string without any input parameter.
Container does not treat Struts2.x, unlike that of Struts1.x, Actions as a request / response couple and struts2.x action can still access the original request and response.
Server side validation are made in action classes in Struts2.x, a much simpler way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With