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.
Posted Date:- 2021-09-13 22:16:31
The differences between both are:
1. The nature of HTML tags is Static whereas the nature of Struts-specific HTML tags is dynamic.
2. HTML is integrated into Struts but Struts have their own tag libraries.
3. The tags for HTML cannot be user-defined but in the case of Struts, the tags can be user-defined.
Posted Date:- 2021-09-13 22:15:40
This is a subclass under the DispatchAction class. This is required for calling the actual methods. For using the LookupDispatchAction, we need a certain set of rules and methods. This controls the forward mechanism by sending the request to the proper resource.
Posted Date:- 2021-09-13 22:14:52
The different actions found in Struts are:
1. ForwardAction
2. IncludeAction
3. DispatchAction
4. LookupDispatchAction
5. SwitchAction
Posted Date:- 2021-09-13 22:14:08
These are the errors that appear when a client or user enters wrong or invalid data for filling up the application. At that moment, for validation, the method Validator() is used which works for the validation on both sides. In order to display the errors on the JSP page, the syntax code is.
Posted Date:- 2021-09-13 22:13:23
In order to combine Velocity templates and Struts, follow the steps:
1. First, you have to set the classpath into Velocity JARs.
2. Then you need to make the web.xml for identifying the Velocity servlet.
3. In the WEB-INF directory, you have to choose velocity toolbox.xml
4. In order to point the view of struts-config from JSPs to velocity templates, you need modifications.
5. For every page that needs to be rendered create the velocity template
Posted Date:- 2021-09-13 22:12:39
During the submission or fill-up of a form, if a client or user makes a mistake in the data for the application that is known as Action Error. The client or user is solely responsible for them. They should be checked as early as possible. If they are not detected fast, they will waste server time and have a bad effect on the quality of codes.
Posted Date:- 2021-09-13 22:11:56
The different drawbacks in Struts are:
>> There is an absence of the flow mechanism in the backward direction.
>> This uses only one controller servlet.
>> There is no exception found in the framework.
>> The Struts Framework is not very transparent.
>> The documentation is very bad in the case of the struts framework.
Posted Date:- 2021-09-13 22:11:15
There are many different technologies that can be used in the view layer. Some of them are:
1. JSP
2. XML/XSLT
3. Velocity Templates
4. HTML
5. WML Files
6. Servlets
Apart from this many other technologies can be also used, but these are the primary ones used for the view layers.
Posted Date:- 2021-09-13 22:10:42
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>
Posted Date:- 2021-09-13 22:10:06
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.
Posted Date:- 2021-09-13 22:09:25
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.
Posted Date:- 2021-09-13 22:08:54
Yes, Struts2 Actions are synchronized as an object is invoked to handle any new incoming request.
Posted Date:- 2021-09-13 22:08:20
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.
Posted Date:- 2021-09-13 22:07:47
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.
Posted Date:- 2021-09-13 22:07:12
The core components of Struts2 are as follows:
1. Interceptors
2. Value Stack
3. Action Context
4. OGNL
5. ActionInvocation
Posted Date:- 2021-09-13 22:06:28
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.
Posted Date:- 2021-09-13 22:04:57
The default result type in struts2 is the dispatcher. It is used to dispatch the JSP pages.
Posted Date:- 2021-09-13 22:04:24
The various types of tags in Struts2 are as follows:
>> 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 Tag
Posted Date:- 2021-09-13 22:03:34
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.
Posted Date:- 2021-09-13 22:02:46
There are five types of constants provided by the Action Interface.
They are:
1. Login
2. Input
3. Success
4. Error
5. None
Posted Date:- 2021-09-13 22:02:13
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.
Posted Date:- 2021-09-13 22:01:25
The ActionInvocation is used to represent the action’s execution state. It holds the action and the interceptor object.
Posted Date:- 2021-09-13 22:00:51
There are multiple steps for the migration of an application from strut 1 to strut 2. The steps are:
Firstly you have to move the Strut 1 Action form.
After moving it, you have to place it in Strut 2 POJO.
Then you have to convert the configuration file of struts 1 i.e. struts-config.xml into the configuration file of struts 2 i.e. struts.xml
Posted Date:- 2021-09-13 22:00:27
There are two different types of Formbeans:
** Request Scope: When the Scope type is request, the values of the form beans are available with the current request.
** Session Scope: When the scope type is a session, the values of the form beans are found for all the requests in the recent session.
Posted Date:- 2021-09-13 22:00:03
If you are asked about this, then remember this is a trick question. There is absolutely no difference between the two, they are the same.
Posted Date:- 2021-09-13 21:59:33
In order to define certain error messages resource bundle.the properties file is required. It is done in input value pairs. This is done for checking all the errors in the whole coding that may have slipped. This way it is ensured that the code is clean since the developer no longer has to worry about the embedded error messages in the code.
Posted Date:- 2021-09-13 21:59:09
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.
Posted Date:- 2021-09-13 21:58:16
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)
Reset () method is used to reset all the ActionForm’s data before the new values are being set. It is called by the struts framework with each request that uses a defined action form.
Syntax: public void reset ((ActionMapping mapping, HttpServletRequest request)
Posted Date:- 2021-09-13 21:57:17
When we want to combine an existing application with struts, we need to use the ForwardAction. ForwardAction is also used whenever one wants to transfer the complete control from one place to another, say, JSP to a local server. ForwardAction is also used when one wants to obtain the benefits of the functionality of struts after the integration with Struts. In this case, Servlets are never written again. Another use of ForwardAction is when a request is forwarded to other resources.
Posted Date:- 2021-09-13 21:56:50
The Struts framework is completely working on MVC architecture. This ensures that the different layers of Struts are separated properly which further ensures the development and the customization of the application easy. Because files of different configurations are used thus the configuration of applications also becomes easy. Struts framework is also open-source software and thus the best part, it is cost-effective!
Posted Date:- 2021-09-13 21:56:28
The Core classes in Struts Framework are:
1. Action Servlet: This is the most important part of the whole application since it works as the backbone of the framework.
2. ActionForm: This is a Java Bean and it is used for referring to forms.
3. Action Class: This is used for handling all the requests.
4. Action Mapping: This is used for the process of mapping within the object and the action.
5. ActionForward: This forwards the results from the controller to the destination.
Posted Date:- 2021-09-13 21:56:03
For the purpose of Validation of form data, the Validator framework is used. The two different validations are:
1. Client-Side Validation
2. Server-Side Validation
Posted Date:- 2021-09-13 21:55:37
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.
Posted Date:- 2021-09-13 21:55:11
To display all validation errors based on the validation rules defined in validation.xml file, we use <html:errors /> tag in our JSP file.
Posted Date:- 2021-09-13 21:54:18
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-13 21:53:56
For JSP configuration details, Web.xml file is used.
Posted Date:- 2021-09-13 21:53:27
Struts Applications use the MVC designs and the flow of request happens in this way:
** The user interacts with the view after clicking on a link or after they submit a form.
** After the interaction takes place, the request is forwarded to the controller.
** The controller is the person held responsible for forwarding the request for better action.
** Action class decides the function which further works for the business logic that is to be implemented.
** The last step is the response, it occurs after the model layer sends it and it is viewed on the screen by the user.
Posted Date:- 2021-09-13 21:52:54
In a Struts application, the action class handles the requests. The action class is the interface between the request (HTTP) and the logic used for developing the application. The RequestProcessor in the action class works as the controller which chooses the proper action for the requests that are received.
Posted Date:- 2021-09-13 21:52:31
Bean Tag Library is a Struts library which can be used for accessing Java beans.
Posted Date:- 2021-09-13 21:51:59
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.
Posted Date:- 2021-09-13 21:51:39
There are three life cycle methods of the Interceptor as mentioned below.
1. init () method
2. intercept () method
3. destroy () method
Posted Date:- 2021-09-13 21:51:13
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.
Posted Date:- 2021-09-13 21:50:31
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.
Posted Date:- 2021-09-13 21:50:07
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.
Posted Date:- 2021-09-13 21:49:51
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.
Posted Date:- 2021-09-13 21:49:36
The prominent features of Struts2 are as follows.
<> In Struts2, the Action class is POJO. We don’t need to inherit any class or implement any interface.
<> 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.
Posted Date:- 2021-09-13 21:48:52
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.
Posted Date:- 2021-09-13 21:47:28
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.
Posted Date:- 2021-09-13 21:46:05
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.
Posted Date:- 2021-09-13 21:45:44
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.
Posted Date:- 2021-09-13 21:43:38
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.
Posted Date:- 2021-09-13 21:43:10