Which is the Best Java Web Framework ?

Struts Framework - Interview Questions and Answers


1. What is Struts ?

Ans. Its a Java / J2EE open source framework used to create scalable Web applications. It is based on MVC Design pattern.

2. What is MVC ?

Ans. Model-View-Controller is a design pattern wherein Model holds the business logic , Controller controls the flow and View takes care of the presentation part of web application.

3. Difference between Struts 1 and Struts 2 ?

Ans. 

ActionServlet is the controller in Struts 1 whereas FilterDispatcher is the controller in Struts 2.

Interceptors were introduced in Struts 2. 

Action classes were singleton in Struts 1.

Struts 2 doesn't have and need form beans as Action classes are used to hold form fields. 

Base Action is an abstract class in Struts 1 whereas its  an interface in Struts 2. 

Struts 2 uses Pull MVC and uses Value Stack technology for View.

4. Difference between filters and Interceptors ?

Ans.

Interceptors were introduced with Struts 2.

Interceptors are mapped to Actions where as Filters are mapped to URL.

Interceptors are called before Actions where Filters are called before Servlet.

Filters are used for tasks like Authentication , URL Redirection whereas Interceptors are used for tasks like Validation , Data loading etc.

Interceptors are used for providing solution for common concerns between actions where Filters are used for common concerns between different url requests.

5. What is Action Chaining ?

Ans. An action calls another action upon completion of first action and so forth.

6. What are the classes used as part of struts framework ?

Ans. Action servlet , Action class , Action Form , Action Mapping , ActionForward

7. Can we have multiple struts config files ?

Ans. Yes we can have multiple struts config files. We need to add the names of those config files in web.xml.

8. What are the contents on web.xml in struts application ?

Ans. Servlet definition , Servlet Mapping , Struts Config files , Landing Page , Plugins - Validation , taglib etc.

9. How is declarative handling of exceptions done in Struts ?

Ans. By defining <global-Exception> tag inside struts config.xml file.

10. What do you know about Validation plugin ?

Ans. Validation plugin can be enabled by making an entry in web.xml. There are 2 xml files -

validation.xml that holds the form bean, its elements and the validation to be performed on them. and validator-rules.xml holds the rules for the validation specified in validation.xml.


11. What validate() and reset() method does ?

Ans. Validate and reset methods are defined in Form Beans. Validation method is used to validate the request parameters where reset method clear Action Form Data members.

12. What configurations are stored in struts configuration file ?

Ans. URL - Action - Form Bean - View Mapping , Interceptors ,  Message Resources.

13. What is controller in Struts ?

Ans. Its the servlet in particular ActionServlet.

14. How many instances of servlet usually run in a struts application ?

Ans. One








We will publish it with credits to you.
Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus




×

Try our new Java Interview Questions Search Tool.

There are more than 1000 questions with practice tests.

It's updated daily and It's Awesome.


×

Try our new Java Practice Test tool.

There are more than 200 questions and expanding quickly. It's updated daily and It's Awesome.