Google News
logo
Java Struts - Interview Questions
What is the differences between Struts1 and Struts2?
Structs1 : 
* Form beans define properties, setters and getters
* Execute() method exposes servlet API for testing
* Multiple tag libraries
* RequestProcessor class present
* Struts1 APIs are tightly coupled with Servlet API and Request and Response objects are passed to action classes execute() method.
* Struts1 action classes are hard to test because of Servlet API coupling.
* Struts1 requires us to create ActionForm classes to hold request params and we need to configure it in the struts configuration file.
* Struts1 uses JSTL Tags and hence are limited.
* Struts1 supports validation through manual validate() method

Structs2 : 
* Getters and Setters are defined in action classes
* Dependency Injection simplifies the testing process
* The single library includes all tags
* Interceptors present
* Struts2 API is loosely coupled with Servlet API and automatically maps the form bean data to action class java bean properties that we mostly use. If however we need reference to Servlet API classes, there are *Aware interfaces for that.
* Struts2 Action classes are like normal java classes and we can test them easily by instantiating them and setting their properties.
* Struts2 request params mapping is done on the fly and all we need is to have java bean properties in action classes or implement ModelDriven interface to provide the java bean class name to be used for mapping.
* Struts2 uses OGNL and provide different kinds of UI, Control and Data Tags. It’s more versatile and easy to use.
* Struts2 support both manual validation as well as Validation framework integration.
Advertisement