YouTube Icon

Interview Questions.

Top 25 Java Struts Interview Questions - Jul 26, 2022

fluid

Top 25 Java Struts Interview Questions

Q1. Why Actionservlet Is Singleton In Struts?

In Struts framework, actionServlet acts as a controller and all the requests made by customers are controlled by using this controller. ActionServlet is based onsingleton design patter as simplest one item desires to be created for this controller elegance. Multiple threads are created later for each user request.

Q2. What Is Struts Validator Framework?

Struts Validator Framework permits us to validate the statistics of each customer side and server facet.

There are two forms of validation supported inside the struts framework:-

  @Clint facet validation (Using java script help and permitting  java script in ur browser).

  @Server website validation (using Validator technique or ActionServlet magnificence and).

There is another way that is defining the rules of validation in validation-rule.Xml report.

When some information validation isn't always gift in the Validator framework, then programmer can generate very own validation common sense, this User Defined Validation common sense may be bind with Validation Framework.

Validation Framework include  XML configuration Files:

@Validator-Rules.Xml report

@Validation.Xml report

Q3. How Many Servlet Controllers Are Used In A Struts Application?

Struts framework works at the concept of centralized manage technique and the whole utility is controlled via a unmarried servlet controller. Hence, we require most effective one servlet controller in a servlet software.

Q4. What Are Disadvantages Of Struts?

Although Struts have big quantity of blessings associated, it additionally requires larger learning curve and also reduces trparency inside the improvement manner.

Struts additionally lack right documentation and for lots of its additives, users are not able to get proper online resources for assist.

Q5. How Properties Of A Form Are Validated In Struts?

For validation of populated homes, validate() approach of ActionForm magnificence is used earlier than managing the control of formbean to Action magnificence.

Q6. Which File Is Used By Controller To Get Mapping Information For Request Routing?

Controller makes use of a configuration document “struts-config.Xml report to get all mapping records to determine which movement to use for routing of person’s request.It work as the router in the network and procedure and map the request to the associated motion or useful resource.

Q7. What Configuration Changes Are Required To Use Resource Files In Struts?

Resource documents (.Residences files) may be utilized in Struts with the aid of adding following configuration entry in struts-config.Xml document:

<message-resources parameter=”com.Login.Struts.ApplicationResources”/>

 

Q8. What Are The Different Kinds Of Actions In Struts?

The one-of-a-kind styles of moves in Struts are:

1.ForwardAction

2.IncludeAction

3.DispatchAction

4.LookupDispatchAction

five.SwitchAction

Q9. How Exceptions Are Handled In Struts Application?

Exceptions are handled in struts by way of using anybody of the following two methods:

Programmatically coping with: In this exception are dealt with through using attempt to trap block in software. Using this programmer can define how to take care of the situation when exception arises.

Declarative dealing with: In this exception handling is completed by using the usage of the XML document. Programmer defines the exception managing good judgment in the XML document. 

There are  methods of defining the exception handling common sense in the XML document:

1.Global Action Specific Exception Handler Definition.

2.Local Action Specific Exception Handler Definition.

Q10. What Design Patterns Are Used In Struts?

Struts is based on version 2 MVC (Model-View-Controller) architecture. Struts controller makes use of the command design pattern and the movement training use the adapter design pattern. The technique() method of the RequestProcessor uses the template approach design sample. Struts also enforce the subsequent J2EE layout patterns.

1.Service to Worker

2.Dispatcher View

3.Composite View (Struts Tiles)

4.Front Controller

5.View Helper

6.Synchronizer Token

 

Q11. What Are The Components Of Struts Framework?

Struts framework consists of following components:

@Based at the Model-View-Controller (MVC) design paradigm, highly isolating all 3 stages:

Model: application nation

View: presentation of information (JSP, HTML)

Controller: routing of the application drift

@A request handler furnished by means of the application developer that is used to  mapped to a selected URI.

@A reaction handler that is used to trfer the manage to any other useful resource to be able to be accountable for completing the reaction.

@A tag library which helps builders to create the interactive form primarily based applications with server pages.

@Java Servlets

@JSP (Java Server Pages)

@Custom Tags

@Message Resources

Q12. What Are The Benefits Of Struts Framework?

Struts is primarily based on MVC and subsequently there is a superb separation of various layers in Struts which makes Struts applications development and customization easy. Use of different configuration files makes Struts packages effortlessly configurable. Also, Struts is open supply and hence, fee powerful.

Q13. In Struts, How Can We Access Java Be And Their Properties?

Bean Tag Library is a Struts library which can be used for having access to Java be.

Q14. What Is Actionmapping?

Action mapping contains all of the deployment information for a selected Action bean. This class is to decide where the results of the Action could be sent as soon as its processing is complete.

Q15. Which Configuration File Is Used For Storing Jsp Configuration Information In Struts?

For JSP configuration information, Web.Xml file is used.

Q16. What Is Lookupdispatchaction?

1.The LookupDispatchAction magnificence is a subclass of DispatchAction.

2.The LookupDispatchAction is used to name the real technique.

Three.For the usage of LookupDispatchAction, first we should generate a subclass with a set of methods.

4.It manipulate the forwarding of the request to the great aid in its subclass.

5.It does a opposite lookup at the aid package deal to get the key after which receives the method whose name is associated with the important thing into the Resource Bundle.

Q17. What Is Dispatchaction?

1.The DispatchAction enable the programmer to combine collectively related feature or class.

2.Using Dispatch Action programmer can integrate the consumer related motion into a single UserAction. Like add user, delete consumer and replace consumer.

3.DispatchAction execute the motion primarily based on the parameter cost it gets from the person.

Q18. What Are The Steps Of Struts Installation?

In order to use Struts framework, we only need to feature Struts.Jar report in our improvement environment. Once jar file is to be had in the CLASSPATH, we are able to use the framework and develop Strut primarily based programs.

Q19. Is Struts Thread Safe?

Yes Struts are thread safe. In Struts, a brand new servlet item is not required to deal with every request; as a substitute a brand new thread of movement class item is used for each new request.

Q20. Which Model Components Are Supported By Struts?

Struts aid all styles of fashions which includes Java be, EJB, CORBA. However, Struts doesn’t have any in-constructed assist for any particular model and it’s the developer’s choice to opt for any model.

Q21. How Duplicate Form Submission Can Be Controlled In Struts?

In Struts, action elegance provides two vital strategies which can be used to keep away from reproduction form submissions.

SaveToken() method of movement elegance generates a completely unique token and saves it in the consumer’s session.IsTokenValid() technique is used then used to test area of expertise of tokens.

Q22. What Are The Core Classes Of Struts Framework?

Following are the center instructions provided by using Struts Framework:

1.Action Class

2.ActionForm Class

three.ActionMapping Class

four.ActionForward Class

five.ActionServlet Class

 

Q23. What Is The Advantage Of Having A Pojo Class As An Action?

The POJO magnificence is mild weight and easy to test with frameworks like Junit. Moreover, there's no need to create separate ActionForms as in struts one to hold the values from the supply web web page. It is executed by a unmarried POJO elegance in struts 2.

Q24. What Is Struts.Devmode?

The struts.DevMode is used to make certain that framework is running in development mode or production mode via putting proper or fake. Struts.DevMode is set to false in manufacturing segment to lessen effect of performance. By default it's miles "fake". 

It is used due to the following reasons:

Resource Reloading: Resource package deal reload on every request

Modification: struts.Xml may be changed with out restarting or redeploying the software

Error Handling: The error happens inside the application can be mentioned, as oppose to production mode.

Q25. When Should Be Opt For Struts Framework?

Struts should be used while any or some of the subsequent conditions are genuine:

1.A relatively strong enterprise stage application improvement is required.

2.A reusable, highly configurable application is required.

Three.A loosely coupled, MVC based utility is required with clear segregation of different layers.




CFG