Top 25+ Struts Interview Questions & Answers [ JAVA TRICKS ] |ACTE
Struts Interview Questions and Answers

Top 25+ Struts Interview Questions & Answers [ JAVA TRICKS ]

Last updated on 04th Jul 2020, Blog, Interview Questions

About author

Dhamodharan (Sr Technical Manager )

High level Domain Expert in TOP MNCs with 8+ Years of Experience. Also, Handled Around 20+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 15212 Ratings 1704
  • These Struts Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Struts .
  • As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer.

Q1.What is Struts? Why you have used struts in your application or project.

Ans:

Struts interview questions answers j2eeAns:

  • This is the first interview questions anyone asks in Struts to get the interview rolling.
  • Most commonly asked during the less senior level.
  • Struts are nothing but open source framework mostly used for making web application whenever we use the term framework means it comprises JSP, servlet, custom tags message resources all in one bundle which makes developer task very easy.
  • It is based on MVC pattern which is model view Controller pattern.

Q2.What are the main classes which are used in struts application?

Ans:

This is another beginner’s level Struts interview question which is used to check how familiar candidate is with Struts framework and API. Main classes in Struts Framework are: 

  • Action servlet: it’s a backbone of web application it’s a controller class responsible for handling the entire request.
  • Action class: using Action classes all the business logic is developed us call model of the application also.
  • Action Form: it’s a java bean which represents our forms and associated with action mapping. And it also maintains the session state its object is automatically populated on the server side with data entered from a form on the client side.
  • Action Mapping: using this class we do the mapping between object and Action.
  • ActionForward: this class in Struts is used to forward the result from controller to destination.

Q3.How exceptions are handled in Struts application?

Ans:

  • This is little tough Struts interview question though looks quite basic not every candidate knows about it. Below is my answer of this interview questions on Struts:

There are two ways of handling exception in Struts:

  • Programmatically handling: using try {} catch block in code where an exception can come and flow of code is also decided by programmer .its a normal java language concept.
  • Declarative handling: There are two ways again either we define <global-Exception> tag inside struts-config.XML file

Q4.How validation is performed in struts application?

Ans:

  • Another classic Struts interview question it’s higher on a level than previous interview questions because it’s related to important validation concept on a web application.
  • In struts validation is performed using validator framework, Validator Framework in Struts consist of two XML configuration files.

1. validator-rules.xml file: which contains the default struts pluggable validator definitions. You can add new validation rules by adding an entry in this file. This was the original beauty of struts which makes it highly configurable.

2. Validation.xml files which contain details regarding the validation routines that are applied to the different Form Beans. To associate more than one validation rule to the property we can specify a comma-delimited list of values. The first rule in the list will be checked first and then the next rule and so on. Answer of this Struts questions gets bit longer but it’s important to touch these important concepts to make it useful.

Q5.What is the Difference between DispatchAction and LookupDispatchAction in Struts Framework?

Ans:

  • This Struts interview question is pretty straight forward and I have put the differences in tabular format to make it easy to read.
  • DispatchAction provides a mechanism for grouping a set of related functions into a single action, thus eliminating the need to create separate actions for each function.
  • An abstract Action that dispatches to the subclass mapped executes method.
  • This is useful in cases where an HTML form has multiple submit buttons with the same name.
  • The button name is specified by the parameter property of the corresponding ActionMapping.

Q6.How you can retrieve the value which is set in the JSP Page in the case of DynaActionForm?

Ans:

  • DynaActionForm is a popular topic in Struts interview questions. DynaActionForm is a subclass of ActionForm that allows the creation of form beans with dynamic sets of properties, without requiring the developer to create a Java class for each type of form bean.
  • DynaActionForm eliminates the need of FormBean class and now the form bean definition can be written into the struts-config.XML file.
  • So, it makes the FormBean declarative and this helps the programmer to reduce the development time.

Q7.what the Validate () and reset () method does?

Ans:

  • This is one of my personal favorite Struts interview questions. validate(): validate method is Used to validate properties after they have been populated, and this , method is  Called before FormBean is passed  to Action.
  • Returns a collection of ActionError as ActionErrors. Following is the method signature for the validate() method.

Q8.How you will make available any Message Resources Definitions file to the Struts Framework Environment?

Ans:

  • Message Resources Definitions file are simple .properties files and these files contain the messages that can be used in the struts project.
  • Message Resources Definitions files can be added to the struts-config.xml file through < message-resources / > tag. 

Q9.What configuration files are used in Struts?

Ans:

ApplicationResources.properties and struts-config.xml these two files are used to between the Controller and the Model.

Q10.Explain Struts work Flow?

Ans:

  • Sometime this Struts interview questions asked as first questions but I recall this now J .
  • Here is the answer to this Struts interview questions

Struts flow and architecture

1) A request comes in from a Java Server Page into the ActionServlet.

2) The ActionServlet having already read the struts-config.xml file knows which form bean relates to this JSP, and delegates work to the validate method of that form bean.

3) The form bean performs the validate method to determine if all required fields have been entered, and performs whatever other types of field validations that need to be performed.

4) If any required field has not been entered, or any field does not pass validation, the form bean generates ActionErrors, and after checking all fields returns back to the ActionServlet.

5) The ActionServlet checks the ActionErrors that were returned from the form beans validate method to determine if any errors have occurred. If errors have occurred, it returns to the originating JSP displaying the appropriate errors.

6) If no errors occurred in the validate method of the form bean, the ActionServlet passes control to the appropriate Action class.

7) The Action class performs any necessary business logic, and then forwards to the next appropriate action (probably another JSP).

Q11.What is Struts Framework? What are its Components?

Ans:

  • Struts is a type of Web Application Development Framework that provides a suitable platform for developing web applications.
  • Struts include Servlets, JSP, Custom tags and Message resources into a unified framework.

Q12.Why do we use Struts?

Ans:

As Struts is based on MVC architecture i.e. Model, View, Controller, it separates Business Logic, Design & Controller, as a result of which it makes the code more simple, maintainable and readable.

Q13.What are the important classes of the Struts Application?

Ans:

Enlisted below are the most important classes of the Struts Application.

  • Action Servlet: It is the controller class and handles all the incoming requests.
  • Action Class: With Action class all the business logic also so-called a Model is developed.
  • Action Form: Action Form is a java bean that associates one or more Action Mappings. It maintains the session state for a web application.
  • Action Mapping: With Action Mapping, we can do the mapping between Object and Action.
  • Action Forward: It is used to forward the result from the Controller to the destination.

Q14.What are the new features of Struts2?

Ans:

The prominent features of Struts2 are as follows.

  • Struts2 has JSP, Free marker, and Valocity for the view component.
  • In Struts2, Front Controller is StrutsPrepareAndExecuteFilter.
  • In Struts2, the configuration file name must be struts.xml and should be placed inside the classes directory.
  • Struts2 uses the concept of Interceptors while processing the request.

Q15.What is MVC?

Ans:

  • MVC stands for Model, View, and Controller and is called the Software Design Pattern for developing web applications.
  • Model: Model is responsible for maintaining the State of Data and Business logic of the application.
  • View: View is responsible to show all data to use i.e. it shows the presentation.
  • Controller: Controller acts as an interface between View and Model. It intercepts all the requests i.e. receives input and commands to Model/View to change accordingly.

Q16.What are Interceptors?

Ans:

  • Interceptors are the object that provides the pre-processing logic before action is called or provides a post-processing logic after the action is called.
  • Interceptors can be used to perform various operations such as Validations, Exception Handling, File Uploading, Displaying intermediate results, etc.

Q17.What are the Life Cycle methods of the Interceptor?

Ans:

There are three life cycle methods of the Interceptor as mentioned below.

init () method

intercept () method

destroy () method

Q18.How is a request handled in Struts2 Application?

Ans:

  • A request in Struts2 Application is handled in the below manner.
  • Firstly, the request received is sent to the server by the user.
  • Then the request is handled by FilterDispatcher that selects an appropriate action for it.
  • The defined interceptors perform pre-processing operations like file upload, exception handling, etc.
  • Now the selected action is executed and the operation is performed.
  • Again the defined interceptors perform post-processing operations like file upload, exception handling, etc.
  • The final result is displayed to the user in the form of the view page.

Q19.What is the function of the Struts.xml File in Struts?

Ans:

  • In the struts.xml file, the user can define all the mapping to actions so that a particular action is called when a particular operation is performed.
  • It is also called as the configuration file and is present under the WEB-INF/classes folder.

Q20.Which Configurations Files are used in Struts?

Ans:

The configurations files used in Struts include:

  • ApplicationResource.properties.
  • Struts-config.xml.

    Subscribe For Free Demo

    Q21.What is the use of Validate () and Reset () methods in Struts?

    Ans:

    • Validate () method is used to validate the properties after they have been populated and it is called before the Form Bean is passed to the action.
    • It returns a collection of action errors.
    • Syntax: Public ActionErrors Validate (ActionMapping mapping, HttpServletRequest request)

    Q22.What do you mean by Value Stack?

    Ans:

    • A Value Stack can be explained as a stack that contains requirement specific objects. The action stays at the top of the stack while executing.
    • The objects are then placed in Value Stack and the user can perform SQL operations on it.

    The various methods of Value Stack are as follows:

    • FindString (): Used to find the string from the given expression.
    • FindValue (): Used to find value from the given expression.
    • Peek (): It gives the object located at the top of the stack.
    • Pop (): It gives the object located at the top of the stack and removes it.
    • Push (): It pushes the object to the top of the stack.

    Q23.What do you mean by Action Context?

    Ans:

    • The Action Context is an object container in which actions are executed.
    • The values that are stored in the Action Context are unique per thread (i.e. Thread Local), as a result of which, we don’t need to make our action thread-safe.
    • By calling the getContext() method of ActionContext class, we can get the reference of ActionContext.
    • It is a static factory method.
    • For Example: ActionContext context = ActionContext.getContext();

    Q24.What is the use of ActionInvocation?

    Ans:

    • The ActionInvocation is used to represent the action’s execution state.
    • It holds the action and the interceptor object.

    Q25.What is the use of OGNL?

    Ans:

    • Object Graph Navigation Language (OGNL) is a strong expression language.
    • It helps to simplify the accessibility of data stored in the ActionContext. OGNL supports interacting with collections i.e. Map, List, and Set.
    • The struts framework helps to set the ValueStack as the root object of OGNL.
    • The action object is pushed into the ValueStack and we can directly access the action property.

    Q26.What are the types of constants present in the Action Interface?

    Ans:

    There are five types of constants provided by the Action Interface.

    They are:

    • Login
    • Input
    • Success
    • Error
    • None

    Q27.How can we create Action Classes in Struts2?

    Ans:

    There are many ways to create Action Classes in Struts2.

    Some of them are as follows:

    • Using Strts2 @Action annotation.
    • Extend the ActionSupport class.
    • By implementing the Action Interface.

    .

    Q28.How can we Handle Exceptions in Struts?

    Ans:

    In Struts, exceptions can be handled in two ways as shown below.

    • Programmatic Exception Handling: In this, we can use Try {} Catch {} block to handle the exception.
    • Declarative Exception Handling: Here, we can define the global exception handling tags in struts-config.xml or define exception handling tags within tags.

    Q29.What are the Types of Tag Libraries in Struts?

    Ans:

    Struts provides many tag libraries to ease software development.

    • Bean Tag Library: Used for accessing Java Beans and its properties.
    • Nested Tag Library: Provides the ability to use nested beans in the application.
    • Logic Tag Library: Used for giving the required output, iteration capability and flow management.
    • HTML Tag Library: Helps to get the required HTML output.
    • Tiles Tag library: Used in applications that have tiles.

    Q30.What are the different types of Struts Actions?

    Ans:

    • Forward Action: With this class, we can control the Struts controller and its functionality, without having to rewrite the existing Servlets.
    • Include Action: Using IncludeAction class to include another resource in the response to the request being processed.
    • Switch Action: Used to switch one resource in one module to another resource in another module.
    • Dispatch Action: Used to combine the related actions into a single class.
    • LookUpAction: Used to drive the action with a key if the action name is not working.

    Q31.What are the different types of tags in Struts2?:

    Ans:

    • Control Tag (If Else tag, Iterator Tag, Merge Tag, Append Tag, Generator Tag, etc.)
    • Data Tag (Action tag, Include Tag, Bean Tag, Date Tag, Param Tag, Property Tag, Push Tag, Set Tag, Text Tag, etc.)
    • Form Tag (All the simple UI Tags.)
    • Ajax TagQ #22) What is the default result type in Struts2?

    Q32.What do you mean by Internationalization? Why do we need it?

    Ans:

    • Internationalization (i18n) is the interceptor that is used for planning and implementing products and services so that they can be easily adapted to specific local languages and cultures i.e. a process called localization.
    • It handles setting locale for the action.
    • It can be used if the user wants to set his/her locale and get data according to the locale provided.

    Q33.What are the Core Components of Struts2?

    Ans:

    • Interceptors
    • Value Stack
    • Action Context
    • OGNL
    • ActionInvocation

    Q34.How can we create Custom Interceptor?

    Ans:

    • We can create the custom interceptor by implementing the Interceptor interface in a class and overriding its three life cycle method i.e. init (), Destroy (), Intercept ().
    • It can also be created by defining the entry of the interceptor in the struts.xml file.

    Q35.What is the functionality of the Token Interceptor in Struts2?

    Ans:

    • The major problem with web applications is the double form submission that results in charging double amounts from the user and storing double values in the database.
    • We can use a token interceptor to solve the double form submission problem.
    • This interceptor is defined in the struts-default package.

    Q36.How to upload files in the Struts2 Application?

    Ans:

    With the help of the File Upload Interceptor, we can upload files in the struts2 application.

    Q37.Is Struts2 Action Synchronized?

    Ans:

    Yes, Struts2 Actions are synchronized as an object is invoked to handle any new incoming request.

    Course Curriculum

    Learn Struts Certification Course to Build Your Skills & Career

    Weekday / Weekend BatchesSee Batch Details

    Q38.Are Struts2 Interceptors Synchronized?

    Ans:

    As Struts2 interceptors are singleton classes and as a new thread is created to handle the request, it is not synchronized and we need to implement them carefully to avoid any issues with the shared data.

    Q39.What is the Front Controller in Struts2?

    Ans:

    StrutsPrepareAndExecuteFilter is the Front Controller class in Struts2, it is also the starting point of every incoming request.

    Q40.How are ValueStack and OGNL linked?

    Ans:

    OGNL is a library through which the ValueStack data or values are manipulated whereas ValueStack is a stack where all values and data related to actions are stored.

    Q41.Write the syntax to display the output page using XML in Struts2?

    Ans:

    Here in Struts2, a user can declare the XML file as shown below:

    • <actionname=”output “class=”com.softwaretestinghelp.actionname”>
    • <result name=”SUCCESS”>output.jsp</result>
    • <result name=”ERROR”>error.jsp</result>

    Q42.Which Design Pattern is followed by the Interceptors?

    Ans:

    Interceptors follow a design pattern based on the intercepting filters.

    Q43.Where is the Plug-in tag found in Struts2? What is the function of the Plug-in tag?

    Ans:

    Plug-in tag is found in the struct-config.xml and is used to tell the user where the properties file that has all the prompt and error message is found.

    Q44.What are the disadvantages of the Struts Framework?

    Ans:

    Some of the disadvantages of the Struts Framework are as follows:

    • Only one servlet controller is used.
    • No proper documentation.
    • Transparency is not full.
    • The approach is inflexible.
    • A lot of things are there to learn.

    Q45. What are the components of Struts Framework?

    Ans:

    Struts framework is comprised of following components:

    • Java Servlets
    • JSP (Java Server Pages)
    • Custom Tags
    • Message Resources

    Q46. What’s the role of a handler in MVC based applications?

    Ans:

    • It’s the job of handlers to transfer the requests to appropriate models as they are bound to the model layer of MVC architecture.
    • Handlers use mapping information from configuration files for request transfer.

    Q47. What’s the flow of requests in Struts based applications?

    Ans:

    Struts based applications use MVC design pattern. The flow of requests is as follows:

    • User interacts with View by clicking any link or by submitting any form.
    • Upon user’s interaction, the request is passed towards the controller.
    • Controller is responsible for passing the request to appropriate action.
    • Action is responsible for calling a function in Model which has all business logic implemented.
    • Response from the model layer is received back by the action which then passes it towards the view where user is able to see the response.

    Q48.  Which file is used by controller to get mapping information for request routing?

    Ans:

    Controller uses a configuration file “struts-config.xml file to get all mapping information to decide which action to use for routing of user’s request.

    Q49.  What’s the role of Action Class in Struts?

    Ans:

    In Struts, Action Class acts as a controller and performs following key tasks:

    • After receiving user request, it processes the user’s request.
    • Uses appropriate model and pulls data from model (if required).
    • Selects proper view to show the response to the user.

    Q50. How an actionForm bean is created?

    Ans:

    actionForm bean is created by extending the class org.apache.struts.action.ActionForm

    • import javax.servlet.http.HttpServletRequest; 
    • import org.apache.struts.action.*; 
    • public class testForm extends ActionForm { 
    • private String Id=null; 
    • private String State=null; 
    • public void setId(String id){
    • this.Id=id; 
    • public String getId(){
    • return this.Id;
    • }
    • public void setState(String state){ 
    • this.State=state; 
    • public String getState(){ 
    • return this.State; 
    • }

    Q51. What are the two types of validations supported by Validator FrameWork?

    Ans:

    • Validator Framework is used for form data validation.

    This framework provides two types of validations:

    • Client Side validation on user’s browser

    Q52. What are the steps of Struts Installation?

    Ans:

    • 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.

    Q53. How client side validation is enabled on a JSP form?

    Ans:

    • In order to enable client side validation in Struts, first we need to enable validator plug-in in struts-config.xml file.
    • This is done by adding following configuration entries in this file.

    Q54. How action-mapping tag is used for request forwarding in Struts configuration file?

    Ans:

    • In Struts configuration file (struts-config.xml), forwarding options are defined under action-mapping tag.
    • In the following example, when a user will click on the hyperlink test.do, request will be forwarded to /pages/testing.jsp using following configurations from struts-config.xml file.

    Q55. How duplicate form submission can be controlled in Struts?

    Ans:

    • 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.

     Q56. In Struts, how can we access Java beans and their properties?

    Ans:

    Bean Tag Library is a Struts library which can be used for accessing Java beans.

     Q57. Which configuration file is used for storing JSP configuration information in Struts?

    Ans:

    For JSP configuration details, Web.xml file is used.

    Q58. What’s the purpose of Execute method of action class?

    Ans:

    • Execute method of action class is responsible for execution of business logic.
    • If any processing is required on the user’s request, it’s performed in this method.
    • This method returns actionForward object which routes the application to appropriate page.

     Q59. What’s the difference between validation.xml and validator-rules.xml files in Struts Validation framework?

    Ans:

    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.

    Course Curriculum

    Get Enroll in Struts Training with Instructor-led Classes

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

     Q60. How can we display all validation errors to user on JSP page?

    Ans:

    To display all validation errors based on the validation rules defined in validation.xml file, we use <html:errors /> tag in our JSP file.

     Q61. What’s declarative exception handling in Struts?

    Ans:

    When logic for exception handling is defined in struts-config.xml or within the action tag, it’s known as declarative exception handling in Struts.

    Q62. What’s DynaActionForm?

    Ans:

    • DynaActionForm is a special type of actionForm class (sub-class of ActionForm Class) that’s used for dynamically creating form beans.
    • It uses configuration files for form bean creation.

    Q63. What configuration changes are required to use Tiles in Struts?

    Ans:

    • To create reusable components with Tiles framework, we need to add following plugin definition code in struts-config.xml file:
    • <plug-in className=”org.apache.struts.tiles.TilesPlugin” >
    • <set-property >

    Q64. What’s the difference between Jakarta Struts and Apache Struts? Which one is better to use?

    Ans:

    Both are same and there is no difference between them.

    Q65. What’s the use of Struts.xml configuration file?

    Ans:

    • Struts.xml file is one the key configuration files of Struts framework which is used to define mapping between URL and action.
    • When a user’s request is received by the controller, controller uses mapping information from this file to select appropriate action class.

    Q66 . How tag libraries are defined in Struts?

    Ans:

    Tag libraries are defined in the configuration file (web.xml) inside <taglib> tag as follows:

    • <taglib>
    • <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    • <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    • </taglib>

    Q67. What’s the significance of logic tags in Struts?

    Ans:

    Use of logic tags in Struts helps in writing a clean and efficient code at presentation layer without use of scriptlets.

    Q68. What are the two scope types for formbeans?

    Ans:

    1. Request Scope: Formbean values are available in the current request only

    2. Session Scope: Formbean values are available for all requests in the current session.

    Q69. How can we group related actions in one group in Struts?

    Ans:

    To group multiple related actions in one group, we can use DispatcherAction class.

    Q70. When should we use SwtichAction?

    Ans:

    • The best scenario to use SwitchAction class is when we have a modular application with multiple modules working separately.
    • Using SwitchAction class we can switch from a resource in one module to another resource in some different module of the application.

     Q71. What are the benefits of Struts framework?

    Ans:

    • Struts is based on MVC and hence there is a good separation of different layers in Struts which makes Struts applications development and customization easy.
    • Use of different configuration files makes Struts applications easily configurable.
    • Also, Struts is open source and hence, cost effective.

    Q72. What steps are required to for an application migration from Struts1 to Struts2?

    Ans:

    Following Steps are required for Struts1 to Struts2 migration:

    • Move Struts1 actionForm to Struts2 POJO.
    • Convert Struts1 configuration file (struts-config.xml) to Struts2 configuration file (struts.xml).

     Q73. How properties of a form are validated in Struts?

    Ans:

    For validation of populated properties, validate() method of ActionForm class is used before handling the control of formbean to Action class.

    Q74. What’s the use of reset method of ActionForm class?

    Ans:

    Reset method of action.

    Form class is used to clear the values of a form before initiation of a new request.

    Q75. What are disadvantages of Struts?

    Ans:

    • Although Struts have large number of advantages associated, it also requires bigger learning curve and also reduces transparency in the development process.
    • Struts also lack proper documentation and for many of its components, users are unable to get proper online resources for help.

    Q76. What’s the use of resourcebundle.properties file in Struts Validation framework?

    Ans:

    • Resourcebundle.properties file is used to define specific error messages in key value pairs for any possible errors that may occur in the code.
    • This approach helps to keep the code clean as developer doesn’t need to embed all error messages inside code.

    Q77. Can I have html form property without associated getter and setter formbean methods?

    Ans:

    For each html form property, getter and setter methods in the formbean must be defined otherwise application results in an error.

    Q78. How many servlet controllers are used in a Struts Application?

    Ans:

    • Struts framework works on the concept of centralized control approach and the whole application is controlled by a single servlet controller.
    • Hence, we require only one servlet controller in a servlet application.

     Q79. For a single Struts application, can we have multiple struts-config.xml files?

    Ans:

    • We can have any number of Struts-config.xml files for a single application.
    • We need following configurations for this:
    • <servlet>
    • <servlet-name>action</servlet-name>
    • <servlet-class>
    • org.apache.struts.action.ActionServlet 
    JAVA Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    Q80. Which model components are supported by Struts?

    Ans:

    • Struts support all types of models including Java beans, EJB, CORBA.
    • However, Struts doesn’t have any in-built support for any specific model and it’s the developer’s choice to opt for any model.

    Q81. When it’s useful to use IncludeAction?

    Ans:

    IncludeAction is action class provided by Struts which is useful when an integration is required between Struts and Servlet based application.

    Q82. Is Struts thread safe?

    Ans:

    • Yes Struts are thread safe.
    • In Struts, a new servlet object is not required to handle each request; rather a new thread of action class object is used for each new request.

     Q83. What configuration changes are required to use resource files in Struts?

    Ans:

    Resource files (.properties files) can be used in Struts by adding following configuration entry in struts-config.xml file:

    Q84. How nested beans can be used in Struts applications?

    Ans:

    • Struts provide a separate tag library (Nested Tag Library) for this purpose.
    • Using this library, we can nest the beans in any Struts based application.

    Q85. What are the Core classes of Struts Framework?

    Ans:

    Following are the core classes provided by Struts Framework:

    • Action Class
    • ActionForm Class
    • ActionMapping Class
    • ActionForward Class
    • ActionServlet Class

    Q86. Can we handle exceptions in Struts programmatically?

    Ans:

    Yes we can handle exceptions in Struts programmatically by using try, catch blocks in the code.

    • try {
    • // Struts code
    • }
    • Catch (Exception e) {
    • // exception handling code
    • }

    Q87. Is Struts Framework part of J2EE?

    Ans:

    Although Struts framework is based on J2EE technologies like JSP, Java Beans, Servlets etc but it’s not a part of J2EE standards.

    Q88. What Are The Tools Used In Debugging?

    Ans:

    • We generally use logs to see the cause of the issue, where the failure is occurring.
    • So for iOS – iPhone configuration utility & for Android Monitor.bat, etc can be used.
    • If you provide logs from these tools to the developer, they can easily understand the cause of the issue.

    Q89. Appium Interview Questions – EdurekaQuestion 45: When To Choose Automation Testing And When To Choose Manual Testing?

    Ans:

    • If the application has new functionality
    • If the application requires testing once or twice
    • Automate Testing

    Q90. Mention Few Disadvantages of Automation Testing.

    Ans:

    • Designing the tools and tests to run software takes a lot of manual, human effort, though there are frameworks and tests ready-made for engineers to use.
    • Even with automated testing, human error is still a factor – tools can be buggy, inefficient, costly, and sometimes even technologically limited in what kinds of tests they can run on their own.

    Q91. What Are The Pre-requisites To Start Automation Testing?

    Ans:

    • The first step is to segregate the different test cases that are to be automated.
    • Following this, you must prepare test data as per the needs of the test cases.
    • Reusable functions need to be written which are frequently used in those test cases.
    • Later test scripts are prepared by using reusable functions and applying loops and conditions wherever necessary.

    Q92. What Are The Differences Between Open Source Tools, Vendor Tools, And In-house Tools?

    Ans:

    • Open source tools are free to use frameworks and applications.
    • Engineers build the tool and have the source code available for free on the internet for other engineers to use.
    • Vendor tools are developed by companies that come with licenses to use, and often cost money.
    • Since they are developed by an outside source, technical support is often available for use.
    • Example vendor tools include WinRunner, SilkTest, Rational Robot, QA Director, QTP, LR, QC, RFT, and RPT.

    Q93. Is Automation Testing A Complete Replacement For Manual Software Testing?

    Ans:

    • No. Proper automation requires as little intervention from humans as possible since the tools used are built to run tests once they are set up.
    • As convenient as this might be, it should not be a complete replacement for manual testing – only for repetitive tasks like load testing, where thousands of virtual users are required. 
    • Engineers should not automate things like test scripts if those scripts can only be expected to run occasionally, nor should they automate code reviews, or bug testing for new builds of software that might require human interaction to detect issues.
    • We can conclude by saying that large-scale, repetitive tasks are a better fit for automation.

    Q94.  How action mapping is configured in Struts?

    Ans:

    Action mappings are configured in the configuration file struts-config.xml under the tag <action-mapping> as follows:

    • <pre><action-mappings>
    • <action path=”/login”
    • type=”login.loginAction”
    • name=”loginForm”
    • input=”/login.jsp”
    • scope=”request”
    • validate=”true”>
    • <forward name=”success” path=”/index.jsp”/>
    • <forward name=”failure” path=”/login_error.jsp”/>
    • </action>
    • </action-mappings>

    Q95. When should be opt for Struts Framework?

    Ans:

    Struts should be used when any or some of the following conditions are true:

    • A highly robust enterprise level application development is required.
    • A reusable, highly configurable application is required.
    • A loosely coupled, MVC based application is required with clear segregation of different layers.

    Q96. Why ActionServlet is singleton in Struts?

    Ans:

    • In Struts framework, actionServlet acts as a controller and all the requests made by users are controlled by this controller.
    • ActionServlet is based on singleton design patter as only one object needs to be created for this controller class.
    • Multiple threads are created later for each user request.

    Q97. What are the steps required for setting up validator framework in Struts?

    Ans:

    Following Steps are required to setup validator framework in Struts: – Wrong Spelling

    • In WEB-INF directory place valdator-rules.xml and validation.xml files.
    • Enable validation plugin in struts-config.xml files by adding following:
    • <plug-in className=”org.apache.struts.validator.ValidatorPlugIn”>
    • <set-property >

     Q98. Which technologies can be used at View Layer in Struts?

    Ans:

    In Struts, we can use any of the following technologies in view layer:

    • JSP
    • HTML
    • XML/XSLT
    • WML Files
    • Velocity Templates
    • Servlets

    Q99. What are the conditions for actionForm to work correctly?

    Ans:

    ActionForm must fulfill following conditions to work correctly:

    • It must have a no argument constructor.
    • It should have public getter and setter methods for all its properties.

    Q100.  Which library is provided by Struts for form elements like check boxes, text boxes etc?

    Ans:

    Struts provide HTML Tags library which can be used for adding form elements like text fields, text boxes, radio buttons etc.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free