Struts Interview Questions and Answers, Struts Interview Questions and Answers Freshers, Struts Interview Questions and Answers, Struts Interview Questions
Before getting on to the Struts interview questions, the student must know that the Struts is a continuously varying field which needs the students as well as professionals to upgrade their skills with the new features and knowledge, to get fit for the jobs associated with Struts. This post related to Struts Interview Questions and Answers, Struts Interview Questions and Answers Freshers, Struts Interview Questions and Answers, Struts Interview Questions will help you let out find all the solutions that are frequently asked in you upcoming Struts interview.
Over thousands of vacancies available for the Struts developers, experts must be acquaintance with all the component of Struts technologies. This is necessary for the students in order to have in-depth knowledge of the subject so that they can have best employment opportunities in the future. Knowing every little detail about Struts is the best approach to solve the problems linked with problem.
APTRON has spent hours and hours in researching about the Struts Interview Questions and Answers, Struts Interview Questions and Answers Freshers, Struts Interview Questions and Answers, Struts Interview Questions that you might encounter in your upcoming interview. All these questions will alone help you to crack the interview and make you the best among all your competitors.
First of all, let us tell you about how the Struts technology is evolving in today’s world and how demanding it is in the upcoming years. In fact, according to one study, most of the companies and businesses have moved to the Struts. Now, you cannot predict how huge the future is going to be for the people experienced in the related technologies.
Hence, if you are looking for boosting up your profile and securing your future, Struts will help you in reaching the zenith of your career. Apart from this, you would also have a lot of opportunities as a fresher.
These questions alone are omnipotent. Read and re-read the questions and their solutions to get accustomed to what you will be asked in the interview. These Struts interview questions and answers will also help you on your way to mastering the skills and will take you to the giant world where worldwide and local businesses, huge or medium, are picking up the best and quality Struts professionals.
This ultimate list of best Struts interview questions will ride you through the quick knowledge of the subject and topics like JavaBeans in Struts, Global Exception Handlers, Relationship to Input. This Struts interview questions and answers can be your next gateway to your next job as a Struts expert.
These are very Basic Struts Interview Questions and Answers for freshers and experienced both.
Q1: Explain Struts.
A1: Struts is open source software used to develop java based web page.
Struts uses Jakarta Packages, Java Servlets, JavaBeans, ResourceBundles, and XML
Struts takes the help of Model View Controller (MVC) architecture. Where Model is referring to business or database, View is referring to the Page Design Code, and Controller is referring to navigational code.
Q2: What is IncludeAction?
A2: The IncludeAction is used to integrate the one action file in another action file.
- It is same as ForwardAction but the only difference is that the resource is present in HTTP response.
- Is used to combine the Struts functionality and control into an application that uses Servlets.
- Use the IncludeAction class to include another resource in the response to the request being processed.
Q3: What are the classes used in Struts?
A3: Struts Framework consists of following classes:
- Action Servlets: used to control the response for each incoming request.
- Action Class: used to handle the request.
- Action Form: it is java bean, used to referred to forms and associated with action mapping
- Action Mapping: used for mapping between object and action.
- Action Forward: used to forward the result from controller to destination.
Q4: What is MVC?
A4: Model View Controller (MVC) is a design pattern used to perform changes in the application.
- Model: Model is referring to business or database. It stores the state of the application. Model has no knowledge of the View and Controller components.
- View: View is referring to the Page Design Code. It is responsible for the showing the result of the user’s query. View modifies itself when any changes in the model happen.
- Controller: Controller is referring to navigational code. Controller will chose the best action for each incoming request, generate the instance of that action and execute that action.
Q5: Describe Validate() and reset() methods.
A5: Validate() Method: this method is used to validate the properties after they are explored by the application.
- Validate method is Called before FormBean is handed to Action.
- This method returns a collection of ActionError.
- Syntax of Validate() Method:
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
Reset() Method: this method is called by the Struts Framework with each request that uses the defined ActionForm.
- Used to reset all the data from the ActionForm
- Syntax of Reset() Method:
public void reset() {}
Q6: What is DispatchAction?
A6: The DispatchAction enable the programmer to combine together related function or class.
- Using Dispatch Action programmer can combine the user related action into a single UserAction. like add user, delete user and update user
- DispatchAction execute the action based on the parameter value it receives from the user.
Q7: What is the difference between ForwardAction and IncludeAction?
A7: The difference between ForwardAction and InculdeAction are:
- IncludeAction is used when any other action is going to intake that action whereas ForwardAction is used move the request from one resource to another resource.
Q8: What is ActionMapping?
A8: In action mapping is the mapping of the action performed by the user or client on the application.
-We specify the action class for a specific user’s action. Like we provide the path or URL and different view based on user event.
-We can also define where control of the page deviate in case of validation error in the form.
-We can include ActionMapping in code like this:
< action-mappings >
< action path=”/ a” type =myclasse.A name=”myForm” >
< forward name=”Login” path=”/login.jsp”/ >
< forward name=”error” path=”/error.jsp”/ >
Q9: What are the two types of validations supported by Validator FrameWork?
A9: Validator Framework is used for form data validation. This framework provides two types of validations:
1. Client Side validation on user’s browser
2. Server side validation
Q10: What are the steps of Struts Installation?
A10: In order to use Struts framework, we only need to add Struts.Jar file in our development environment. Once jar file is available in the CLASSPATH, we can use the framework and develop Strut based applications.
Q11: How duplicate form submission can be controlled in Struts?
A11: In Struts, action class provides two important methods which can be used to avoid duplicate form submissions.
saveToken() method of action class generates a unique token and saves it in the user’s session. isTokenValid() method is used then used to check uniqueness of tokens.
Q12: In Struts, how can we access Java beans and their properties?
A12: Bean Tag Library is a Struts library which can be used for accessing Java beans.
Q13: Which configuration file is used for storing JSP configuration information in Struts?
A13: For JSP configuration details, Web.xml file is used.
Q14: What’s the difference between validation.xml and validator-rules.xml files in Struts Validation framework?
A14: In Validation.xml, we define validation rules for any specific Java bean while in validator-rules.xml file, standard and generic validation rules are defined.
Q15: How can we display all validation errors to user on JSP page?
A15: To display all validation errors based on the validation rules defined in validation.xml file, we use tag in our JSP file.
Q16: What is the difference between struts1 and struts2?
A16:
No. | Struts1 | Struts2 |
1) | Action class is not POJO. You need to inherit abstract class. | Action class is POJO. You don’t need to inherit any class or implement any interface. |
2) | Front controller is ActionServlet. | Front Controller is StrutsPrepareAndExecuteFilter. |
3) | It uses the concept of RequestProcessor class while processing request. | It uses the concept of Interceptors while processing the request. |
4) | It has only JSP for the view component. | It has JSP, Freemarker, Valocity etc. for the view component. |
5) | Configuration file name can be [anyname].xml and placed inside WEB-INF directory. | Configuration file must be struts.xml and placed inside classes directory. |
6) | Action and Model are separate. | Action and Model are combined within action class. |
Q17: What is interceptor?
A17: Interceptor is an object i.e. invoked at preprocessing and postprocessing of a request. It is pluggable.
Q18: What is OGNL?
A18: OGNL is an expression language of struts2. It stands for Object Graph Navigation Language.
Q19: What does modelDriven interceptor?
A19: The modelDriven interceptor makes other model as the default object of ValueStack. By default, action is the default object of ValueStack.
Q20: What is the use of jsonValidation?
A20: The jsonValidation interceptor is used to perform asynchronous validation. It works with validation and workflow interceptors.
Q21: What does i18n interceptor?
A21: The i18n interceptor is used to provide multi lingual support for struts application.
Q22: Describe the two types of Formbeans.
A22: There are two different types of Formbeans:
** Request Scope: When the Scope type is request, the values of the formbeans are available with the current request.
** Session Scope: When the scope type is session, the values of the formbeans are found for all the requests in the recent session.
Q23: Explain the complete Struts Validator Framework.
A23: The Struts Validator Framework helps us in validating the data for both the client’s side and the server’s side. If some data is missing while validation or some data is not validated, the programmer is free to add their own concept or logic for validation. This validation logic is further bind with the framework. The validation framework has two different XML files- Validator-Rules.xml file and Validation.xml file.
Q24: What is meant by Custom Tags?
A24: These are customised tags by the users that they can use in the application depending on their needs. If a JSP page with custom tags or user defined tags is translated then the custom also gets translated. Because the tags are reusable, they also help in better development.
Q25: Mark the differences between HTML tags and Strut specific HTML Tags.
A25: The differences between the both are:
- The nature of HTML tags is Static whereas the nature of Struts specific HTML tags is dynamic.
- HTML is an integrated in Struts but Struts have their own tag libraries.
- The tags for HTML cannot be user defined but in case of Struts the tags can be user defined.
Q26: What are the classes used in Struts?
A26: Struts Framework consists of following classes:
Action Servlets: Used to control the response for each incoming request.
Action Class: Used to handle the request.
Action Form: It is java bean, used to referred to forms and associated with action mapping.
Action Mapping: Used for mapping between object and action.
Action Forward: Used to forward the result from controller to destination.
Q27: Describe Validate() and reset() methods.
A27: Validate() Method:
– This method is used to validate the properties after they are explored by the application.
– Validate method is Called before FormBean is handed to Action.
– This method returns a collection of ActionError.
Syntax :
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
Reset() Method:
– This method is called by the Struts Framework with each request that uses the defined ActionForm.
– Used to reset all the data from the ActionForm.
Syntax :
public void reset() {}
Q28: What are the loop holes of Struts?
A28: The drawbacks of Struts are following:
– Absence of backward flow mechanism.
– Only one single controller Servlets is used.
– Bigger learning curve.
– Worst documentation.
– No exception present in this framework.
– Less transparent.
– Rigid approach.
– With struts 1, embedding application into JSP can’t be prevented.
– Non-XML compliance of JSP syntax.
Q29: What is role of Action Class?
A29: – An Action class in the struts application is used to handle the request.
– It acts as interface or communication medium between the HTTP request coming to it and business logic used to develop the application.
– Action class consists of RequestProcessor which act as controller. This controller will choose the best action for each incoming request, generate the instance of that action and execute that action.
– This should be in thread-safe manner, because RequestProcessor uses the same instance for no. of requests at same time.
Q30: What is struts.devMode?
A30: The struts.devMode is used to make sure that framework is running in development mode or production mode by setting true or false. struts.devMode is set to false in production phase to reduce impact of performance. By default it is “false”. It is used because of the following reasons:
Resource Reloading: Resource bundle reload on every request
Modification: struts.xml can be modified without restarting or redeploying the application
Error Handling: The error occurs in the application will be reported, as oppose to production mode.
Q31: What design patterns are used in Struts?
A31: Struts is based on model 2 MVC (Model-View-Controller) architecture. Struts controller uses the command design pattern and the action classes use the adapter design pattern. The process() method of the RequestProcessor uses the template method design pattern. Struts also implement the following J2EE design patterns.
- Service to Worker
- Dispatcher View
- Composite View (Struts Tiles)
- Front Controller
- View Helper
- Synchronizer Token
Q32: What is the difference between session scope and request scope when saving formbean ?
A32: when the scope is request,the values of formbean would be available for the current request.
when the scope is session,the values of formbean would be available throughout the session.
Q33: What is SwitchAction?
A33: The SwitchAction class provides a means to switch from a resource in one module to another resource in a different module. SwitchAction is useful only if you have multiple modules in your Struts application. The SwitchAction class can be used as is, without extending.
Q34: What is DynaActionForm?
A34: A specialized subclass of ActionForm that allows the creation of form beans with dynamic sets of properties (configured in configuration file), without requiring the developer to create a Java class for each type of form bean.
Q35: How to display validation errors on jsp page?
A35: tag displays all the errors. iterates over ActionErrors request attribute.
Q36: What is difference between ActionForm and DynaActionForm?
A36:
- An ActionForm represents an HTML form that the user interacts with over one or more pages. You will provide properties to hold the state of the form with getters and setters to access them. Whereas, using DynaActionForm there is no need of providing properties to hold the state. Instead these properties and their type are declared in the struts-config.xml
- The DynaActionForm bloats up the Struts config file with the xml based definition. This gets annoying as the Struts Config file grow larger.
- The DynaActionForm is not strongly typed as the ActionForm. This means there is no compile time checking for the form fields. Detecting them at runtime is painful and makes you go through redeployment.
- ActionForm can be cleanly organized in packages as against the flat organization in the Struts Config file.
- ActionForm were designed to act as a Firewall between HTTP and the Action classes, i.e. isolate and encapsulate the HTTP request parameters from direct use in Actions. With DynaActionForm, the property access is no different than using request.getParameter( .. ).
- DynaActionForm construction at runtime requires a lot of Java Reflection (Introspection) machinery that can be avoided.
Q37: What is the life cycle of ActionForm?
A37: The lifecycle of ActionForm invoked by the RequestProcessor is as follows:
- Retrieve or Create Form Bean associated with Action
- “Store” FormBean in appropriate scope (request or session)
- Reset the properties of the FormBean
- Populate the properties of the FormBean
- Validate the properties of the FormBean
- Pass FormBean to Action
Struts Conclusion Interview FAQs
We know the list of Struts Interview Questions and Answers, Struts Interview Questions and Answers Freshers, Struts Interview Questions and Answers, Struts Interview Questions is overwhelming but the advantages of reading all the questions will maximize your potential and help you crack the interview. The surprising fact is that this Struts interview questions and answers post covers all the basic of the Struts technology and you have to check out the FAQs of different components of Struts too.
However, you will be asked with the questions in the interview related to the above mentioned questions. Preparing and understanding all the concept of Struts technology will help you strengthen the other little information around the topic.
After preparing these interview questions, we recommend you to go for a mock interview before facing the real one. You can take the help of your friend or a Struts expert to find the loop holes in your skills and knowledge. Moreover, this will also allow you in practicing and improving the communication skill which plays a vital role in getting placed and grabbing high salaries.
Remember, in the interview, the company or the business or you can say the examiner often checks your basic knowledge of the subject. If your basics is covered and strengthened, you can have the job of your dream. The industry experts understand that if the foundation of the student is already made up, it is easy for the company to educate the employ towards advance skills. If there are no basics, there is no meaning of having learnt the subject.
Therefore, it’s never too late to edge all the basics of any technology. If you think that you’ve not acquired the enough skills, you can join our upcoming batch of Struts Training in Noida. We are one of the best institute for Struts in noida which provide advance learning in the field of Struts Course. We’ve highly qualified professionals working with us and promise top quality education to the students.
We hope that you enjoyed reading Struts Interview Questions and Answers, Struts Interview Questions and Answers Freshers, Struts Interview Questions and Answers, Struts Interview Questions and all the FAQs associated with the interview. Do not forget to revise all the Struts interview questions and answers before going for the Struts interview. In addition to this, if you’ve any doubt or query associated with Struts, you can contact us anytime. We will be happy to help you out at our earliest convenience. At last, we wish you all the best for your upcoming interview on Struts Technology.