>> 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.
Posted Date:- 2021-09-14 05:59:20
>> 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.
Posted Date:- 2021-09-14 05:57:41
Exceptions in Struts can be handled in two ways, as shown below.
Programmatic Exceptions Handling: To handle the exception, we can utilize the Try {} Catch {} block.
Declarative Exception Handling: In struts-config.xml, we can define global exception handling tags or exception handling tags within tags.
Posted Date:- 2021-09-14 05:56:31
The Web.xml file is used for JSP configuration details.
Posted Date:- 2021-09-14 05:55:30
Bean Tag Library is a Struts library for interacting with Java beans.
Posted Date:- 2021-09-14 05:54:46
The execAndWait interceptor which is also called as ExecuteAndWait is used to show interim or wait for results.
Posted Date:- 2021-09-14 05:54:16
All parameters on the ValueStack are set by the params interceptor which is also called parameters.
Posted Date:- 2021-09-14 05:53:29
To make software development easier, Struts includes a number of tag libraries.
1. Bean Tag Library: This library is used to access Java Beans and their properties.
2. The Nested Tag Library: This allows you to use nested beans in your application.
3. Logic Tag Library: Provides the appropriate output, as well as iteration and flow management.
4. HTML Tag Library: Assists in obtaining the desired HTML output.
5. Tiles Tag Library: Used in tile-based applications.
Posted Date:- 2021-09-14 05:52:48
All we have to do to use the Struts framework is add the Struts.Jar file to our development environment. We may use the framework and construct Strut-based applications after the jar file is in the CLASSPATH.
Posted Date:- 2021-09-14 05:51:43
The Interceptor has three different life cycle approaches, as listed below.
<> init() method
<> destroy() method
<> intercept() method
Posted Date:- 2021-09-14 05:51:03
An abstract package usually characterizes inheritable segments, for example, interceptor, different interceptor stacks, result types, etc. But that doesn’t contain any actions. The way we announce a package as abstract is through the package elements attribute as abstract and setting the figure to “true.†By default in case, the abstract attribute is not specified it is false. Struts-default.xml is a major example of an abstract package.
Posted Date:- 2021-09-14 05:49:50
With the purpose of Validation of form information, Validator system is utilized. The two different validations are:
<> Customer Side Validation
<> Server-Side Validation
Posted Date:- 2021-09-14 05:49:12
Working with error tags isn’t as complex as it looks. Error labels can be put in any place by including <html: errors/> into JSP. Not at all like others, error tags don’t have a body it also does not consist of any characteristics. The main function the error tag performs is to show the error in the place where the mistake tag is put utilizing three highlights – the header, the body and the footer.
Posted Date:- 2021-09-14 05:47:29
Users of a web application may submit wrong information or no data at all. These errors must be gotten as near to the user interface as could be possible, rather than sitting tight for the center level or the database to tell segment can’t be inserted in the database because of expecting a non-null value.
Following are the outcomes of such programming practice:
<> Wastage of server time and assets. Like the request, this wastes time and assets also fail.
<> The negative effect on code quality as the probability of entering invalid information must be checked while utilizing or coding for business logic as they are the hardest codes of the framework and contain enough squares for if-else.
Posted Date:- 2021-09-14 05:46:56
The struts.dev Mode is utilized to ensure that the system is running in development mode or production mode by setting true or false. Struts.dev Mode is set to false production stage to diminish the effect of execution. As a matter, of course, it is “false.†It is utilized due to the accompanying reasons:
>> Asset Reloading: Resource package reload on each request
>> Modification: struts.xml can be modified without restarting or redeploying the application
>> Mistake Handling: The error happens in the application will be accounted for, as opposed to production mode.
Posted Date:- 2021-09-14 05:46:07
Inner class: classes that are characterized by different classes.
>> The setting is a relationship performed between two different classes.
>> An inner class can get to private members and information.
>> Inner classes have two advantages:
>> Name control
>> Access control
Anonymous class: This class is a class characterized inside a technique without a name.
>> It is instantiated and pronounced in a similar strategy.
>> It doesn’t have explicit constructors.
Posted Date:- 2021-09-14 05:43:17
Struts ought to be utilized when any or some of the accompanying conditions are valid:
<> Highly robust venture level application development is needed.
<> A reusable, highly configurable application is needed.
<> Loosely coupled, MVC established application is required with the clear isolation of different layers.
Posted Date:- 2021-09-14 05:42:05
When we need to join a current application with struts, we have to utilize the Forward Action. Forward Action is also utilized at whatever point one needs to transfer the entire control starting with one place then onto the next, say, JSP to a nearby server. The Forward Action is also utilized when one needs to acquire the advantages of the usefulness of struts after the integration with Struts. For this situation, Servlets are never written again. Another utilization of forwarding Action is when a request is sent to different assets.
Posted Date:- 2021-09-14 05:40:47
Struts provide HTML Tags library which can be used for adding form elements like text fields, text boxes, radio buttons etc.
Posted Date:- 2021-09-14 05:39:30
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.
Posted Date:- 2021-09-14 05:38:59
In Struts, we can use any of the following technologies in view layer:
JSP
HTML
XML/XSLT
WML Files
Velocity Templates
Servlets
Posted Date:- 2021-09-14 05:37:09
Although Struts framework is based on J2EE technologies like JSP, Java Beans, Servlets etc but it’s not a part of J2EE standards.
Posted Date:- 2021-09-14 05:36:42
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.
Posted Date:- 2021-09-14 05:36:10
1.The LookupDispatchAction class is a subclass of DispatchAction.
2.The LookupDispatchAction is used to call the actual method.
3.For using LookupDispatchAction, first we should generate a subclass with a set of methods.
4.It control the forwarding of the request to the best resource in its subclass.
5.It does a reverse lookup on the resource bundle to get the key and then gets the method whose name is associated with the key into the Resource Bundle.
Posted Date:- 2021-09-14 05:35:42
The different kinds of actions in Struts are:
1.ForwardAction
2.IncludeAction
3.DispatchAction
4.LookupDispatchAction
5.SwitchAction
Posted Date:- 2021-09-14 05:35:10
Struts should be used when any or some of the following conditions are true:
1.A highly robust enterprise level application development is required.
2.A reusable, highly configurable application is required.
3.A loosely coupled, MVC based application is required with clear segregation of different layers.
Posted Date:- 2021-09-14 05:34:42
Resource files (.properties files) can be used in Struts by adding following configuration entry in struts-config.xml file:
<message-resources parameter=â€com.login.struts.ApplicationResourcesâ€/>
Posted Date:- 2021-09-14 05:34:18
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.
Posted Date:- 2021-09-14 05:32:36
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.
Posted Date:- 2021-09-14 05:32:08
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.
Posted Date:- 2021-09-14 05:31:21
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.
Posted Date:- 2021-09-14 05:30:55
In Struts framework, actionServlet acts as a controller and all the requests made by users are controlled by this controller. ActionServlet is based onsingleton design patter as only one object needs to be created for this controller class. Multiple threads are created later for each user request.
Posted Date:- 2021-09-14 05:30:23
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.
Posted Date:- 2021-09-14 05:29:58
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.
Posted Date:- 2021-09-14 05:29:27
All applications have specific requests taking a long execution time. Nothing irritates a user more than having no feedback for a long time. Struts 2 provides an inbuilt interceptor execAndWait to handle this situation. This interceptor helps in providing user an intermediate feedback while the request completes execution.
Posted Date:- 2021-09-14 05:28:18
The ValueStack is a storage area holding all data associated with processing of a request. The ValueStack is per-request. Any value placed on the stack during request processing is accessible later in the processing of same request. Data is placed on the Value Stack by various interceptors and this is available while rendering the view. OGNL is the preferred way of accessing values on the ValueStack.
Posted Date:- 2021-09-14 05:27:36
Struts framework offers a number of built-in validators which are called as bundled validators. These validators are for input validations such as email, phone number, user id.
Struts offer the following bundled validators.
requiredstring validator
stringlength validator
email validator
date validator
int validator
double validator
url validator
regex validator
Posted Date:- 2021-09-14 05:27:08
Validation error arises when a user enters invalid data format into the form. In order to validate this data, Struts enables the developer or programmer with the Validator() method for validating the data from the client side as well as the server side. You can display errors in the JSP page by using this syntax:
SYNTAX: <html:error/>
Posted Date:- 2021-09-14 05:25:23
ActionMapping represents the information that is known to RequestProcessor about the mapping of a specific request to a specific Action class. This instance is used to select an Action and then passing on to that Action, thus providing access to configuration information included in the ActionMapping object.
Posted Date:- 2021-09-14 05:24:35
validate() is like a hook that can be overridden by different subclasses for performing validations on incoming data. This method gets called after a Form Bean gets populated with incoming data. This method includes return type ActionErrors.
Syntax is:
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
reset() is a method that gets overridden by subclasses. It is a hook that gets summoned before FormBean gets populated with request data from HTML. Using this method, all form fields get reset.
Syntax is:
public void reset() {}
Posted Date:- 2021-09-14 05:24:11
ApplicationResources.properties and struts-config.xml these two files are used to between the Controller and the Model.
Posted Date:- 2021-09-14 05:23:20
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. Example: < message-resources parameter= MessageResources / >
Message resource definition files can available to the struts environment in two ways
1. using web.xml as
<servlet>
<servlet-name>action<servlet-name>
servlet-class>org.apache.struts.action.ActionServlet<servlet-class>
<init-param>
<param-name>application<param-name>
<param-value>resource.Application<param-value>
</servlet>
2.
<message-resource key=â€myResorce†parameter=â€resource.Application†null=â€falseâ€>
Posted Date:- 2021-09-14 05:22:52
Following Steps are required for Struts1 to Struts2 migration:
1. Move Struts1 actionForm to Struts2 POJO.
2. Convert Struts1 configuration file (struts-config.xml) to Struts2 configuration file (struts.xml)
Posted Date:- 2021-09-14 05:21:49
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.
Posted Date:- 2021-09-14 05:21:20
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.
Posted Date:- 2021-09-14 05:21:06
To group multiple related actions in one group, we can use DispatcherAction class.
Posted Date:- 2021-09-14 05:20:18
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.
Posted Date:- 2021-09-14 05:20:02
Use of logic tags in Struts helps in writing a clean and efficient code at presentation layer without use of scriptlets.
Posted Date:- 2021-09-14 05:19:42
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.
Posted Date:- 2021-09-14 05:18:46
Both are same and there is no difference between them.
Posted Date:- 2021-09-14 05:18:30