In this article, the interview questions and answers on struts are discussed with appropriate answers. Today, getting a job is not easy and you must have a good knowledge on all the major concepts. Additionally, thorough preparation is mandatory for a candidate to face an interview confidently. This article is helpful for the candidate who is attending an interview on the java platform. Most of the people feel nervous due to lack of preparation. You cannot do well in an interview without preparation, even if you are talented and have a good knowledge. The questions discussed in this article are the frequent questions asked by the employers in an interview.
1. Define MVC?
MVC design pattern to help control changes. Interface is decoupled from data and business logic by the MVC.
The core functionality of the application is present in the model. The state of application is encapsulated by the model. The only functionality with model is state. It has a nothing to do with view and controller.
The presentation of the model is given by the view. View is nothing but the look of the application. Model getters are gained access by the view but the knowledge of setters is nil. Additionally, it has a nothing to do with controller. When there are any changes to the model then view must be notified.
Controller reacts to the input of user. The model is created and set by the controller.
2. Define framework?
Set of classes constitute a framework which permits us to use library in an effective way for particular requirement.
3. Define struts framework?
It is an open-source framework used for developing web applications which are based on MVC-2 architecture. Java Servlet API is used and extended by it. The architecture of struts is robust and is mainly used for applications development of any size. The framework related to struts is easy to develop reliable and scalable web applications in java language.
4. Name the components of struts?
Model, view and controller are the components of struts.
Components such as business processes or business logic and data come under model.
The components of view are JSP and HTML.
Controller component is a Action Servlet that work as a front controller in effectively handling requests.
5. Define ActionServlet?
ActionServlet is simple Servlet which is considered as a backbone for all the applications of struts. It is the vital controller component that effectively handles requests of the clients and identifies the action processing requests. It functions like an Action factory by creating Action classes based on the request of users.
6. Define the role of ActionServlet?
The role of the controller is performed by the ActionServlet:
- User requests are processed.
- Determine the achievement of user based on the request.
- If it is required, data from model is pulled to give to appropriate view.
- Choose the perfect view to respond correctly to the user.
- Most of the grunt work is allocated to Action Classes.
- Clean-up and initialization resources are handled by it.
7. Define Action Form?
It is a Java Bean representing inputs of form which contains request parameters from view referencing Action bean.
8. Define Action Mapping?
All the deployment information for specific Action bean is present in the Action Mapping. This class determines where the Action results are sent after completing the processing.
Tag libraries are:
HTML tags: tags for creating view components such as buttons, forms, etc are provided by these HTML tags.
Bean tags: beans and their properties are gained access using bean tags.
Nested tags: to work with nested context, nested tags are helpful.
Logic tags: presentation logics are provided by logic tags that remove script lets needs.
9. Define design patterns in struts?
Struts are based on MVC architecture. The following J2EE design patterns are implemented by the struts:
- Dispatcher view
- Front controller
- Service to worker
- Synchronizer token
- View helper
- Composite view
10. Define struts tag libraries?
To ease the web applications development, multiple tag libraries are provided by struts.
HTML tag library, bean tag library, nested tag library, template tag library are the tag libraries of struts.
11. What are struts disadvantages?
Disadvantages of struts are on application performance while using advanced tag such as nested-loop.
12. What is struts navigation flow?
The struts navigation flow is: previously displayed view makes a request. The request is reached to the ActionServlet that acts as a controller. The logic on model components related to the application is performed by the Action class. After completing processing by Action, a control to Action Servlet is returned. Request completes when Action Servlet responds by passing request to view and the result of an action is represented by this view.
13. Distinguish struts 1.0 and struts 1.1?
- Nested tags
- Admin actions removal
- The struts validator
- Request processor class
- Changing to struts-config.xml and web.xml
- In struts base Action class, perform () method is replaced by execute ()
- Declarative exception handling
- Dynamic ActionForms
- Many more
14. Define token feature in struts?
If the user clicks submit button for many times before sending the response back the duplicate form submission problem occurs. This results in inconsistent transactions and must be prevented. This problem in struts can be managed effectively by using the methods such as saveToken () and TokenVaild () of the Action class. A token is created by saveToken () method and it is saved in the current session of user whereas the token stored in current session of user is same as that pass request parameter is checked by is TokenValid ().
15. What are demerits of struts?
Harder to learn and high learning curve are the disadvantages of struts.
16. How to install struts?
Usually, you can add the JAR file of struts to java development environment to develop applications with struts. Strut classes are used as a part of own application. Complete instructions are provided to compile own struts JAR from scratch as complete source code is available for struts. Usually, standard WAR file is used to develop strut applications. Often, a WAR file is simply deposited on the application server and it should be installed automatically. Else, step by step instructions for different Servlet container are available.
17. Where can I use struts?
The package of struts comes with users guide to introduce underlying technologies and framework to the people. Several components have own in-depth guide for the developers which cover advanced topics. Complete Java docs are present along with source code. These are bundled as self-installing application for convenience. The mailing list of struts is active and the posts from the new users are welcomed.
18. Define a connection pool?
A set of equal database connection objects is known as a connection pool.
19. Who make struts?
Apache Software Foundation host struts as part of Jakarta project, Ant, Tomcat and Velocity.
20. Why it is called struts?
The designers make use remind invisible underpinnings that hold bridges, houses and buildings when we are on stilts. The role of strut is reflected by this perfect description in creating web applications.
21. Distinguish Apache struts and Jakarta struts?
Jakarta struts and Apache struts are same. Initially, struts are created by Craig McClanahan and in the year 2000, it was donated to Apache Foundation. It is developed as Jakarta project and in the year 2004, it became formal Apache Project.
22. Name the super class of Action Form and Action?
Action Form and Action do not have immediate super class and object class is considered as the super class for Action Form and Action.
The candidate who gives all correct and appropriate answers for the questions raised by the employers is hired by the company. These are the questions asked by the employer in the technical round of an interview. The candidate who clears technical round is almost hired by the company as it is the typical round in the interview process.