• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Struts2 » Struts2

Struts2

Struts 2 Actions

By Dinesh Thakur

If you are working on Struts2, Actions are the heart and soul of the Struts2 MVC web framework. A user sends a HTTP request from its web browser which is in the form of a URL and it represents an Action. The framework selects an appropriate Action class based on the mappings available in struts.xml.

The term “action” refers to an associate operation that the application is able to perform. Struts2 actions has default entry point are execute () method, where the execution of an action class start. An action is a servlet (controller) i.e. is used to receive the request and invoke business related function for a given URL, and then mapping the response into a model. An action can also return more than one kind of results depending on the complexity of the business logic. It is used to invoke actions from JSP page.

Optionally we can extend the ActionSuppport class which implements six interfaces including Action interface. The Action interface is as follows

Field Name

Description

public static final String SUCCESS= “success”;

Execution of action was successful

public static final String NONE = “none”;

Successful execution but no view.

public static final String ERROR= “error”;

Execution of action failed.

public static final String INPUT = “input”;

The action execution requires more input in order to succeed.

public static final String LOGIN = “login”;

The Action execution needs that user is not logged in.

public String execute() throws Exception;

 

We have to extend ActionSuppport class which implements action interface, so we can use String constants SUCCESS and ERROR like this.

Role of action:

• Actions provide Encapsulation:

  The role of this encapsulation is to hold the business logic. Actions are invoked by calling the execute ()   method.

• Action helps to carry data

• Action returns control string

• Struts2 supports using POJOs as Actions, which enable us to create action classes without implementing any interface and extending and class.

Strust2 Action Example

The Application’s first Page is the default.jsp; in which user input his name, email and address.

The default.jsp (Client View) uses a struts2 HTML/JSP tags, which is used to generate the content of the default.jsp page. In the Client view code, the Action attribute of <s:form /> tag’s is represents the URL to which the form will be submitted. The Action attribute is used to find the action mapping in the struts.xml configuration file.

Here is the code for default.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
     <title>Struts2 Action Example</title>
  </head>
   <body>
        <table border='0' width='480px' cellpadding='0' cellspacing='0' align='center'>
          <tr>
              <td></td>
              <td align='left'><h2>Enter Client Detail</h2></td>
          </tr>
          <s:form action="ClientAction" method="Post" theme="simple">
             <tr>
                 <td align='right'><b>Name : &nbsp;&nbsp;</b></td>
                 <td><s:textfield key="name" theme="simple" /></td>
             </tr>
                 <tr> <td>&nbsp;</td> </tr>
             <tr>
                 <td align='right'><b>Email : &nbsp;&nbsp;</b></td>
                 <td><s:textfield key="email" theme="simple" /></td>
             </tr>
                 <tr> <td>&nbsp;</td> </tr>
             <tr>
                 <td align='right'><b>Address : &nbsp;&nbsp;</b></td>
                 <td><s:textfield key="address" theme="simple" /></td>
             </tr>
                 <tr> <td>&nbsp;</td> </tr>
             <tr>
                 <td></td>
                 <td align='left'><s:submit value="Submit" theme="simple"></s:submit></td>
              </tr>
            </s:form>
        </table>
   </body>
</html>

In this Application, we have some logic in the execute method. If client enter the String attribute value of name, email and address, we return SUCCESS as the result otherwise we return ERROR as the result. Now, let us see our struts.xml file as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
            "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <constant name="struts.ui.templateDir" value="template" /> 
    <constant name="struts.ui.theme" value="simple" />
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <package name="default" extends="struts-default">
                        <action name= "ClientAction" class= "com.ecomputernotes.ClientAction" method="execute">
             <result name="success">/client.jsp</result>
             <result name="error">/error.jsp</result>
        </action>
      
    </package>
</struts>

In our Application’s Action Class, we will embed some Business logic in the execute method. When execute () method completes, it return a string value either “SUCCESS” or “ERROR”. This string value is used for result element in struts.xml file. Now, let us see our ClientAction.java file as follows:

package com.ecomputernotes;
import com.opensymphony.xwork2.ActionSupport;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ClientAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private String email;
private String name;
private String address;
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address=address;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String execute() throws Exception {
if(getName().equals("") || getName()==null  || getAddress().equals("") || getAddress()==null || getEmail().equals("") || getEmail()==null) {
            return ERROR;
}
else
{
return SUCCESS;
}
}
}

The Error result is shown by error.jsp. When the user leaves any field empty in the default.jsp, then error.jsp page is displayed. This page displays only when there is some error on default.jsp. Now, let us see our error.jsp file as follows:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>Struts2 Action Example</title>
   </head>
        <body>
           <h1>Error</h1>
           <hr/>
              <a href="default.jsp">HOME</a>
              <br/> <br/> <br/>
              <b>Error</b>
                  This Reasons for shown this error page is:
              <ul class ="bold">
                 <li>Any Field left blank.</li>
              </ul>
        </body>
</html>

When the client submit name, email and address from default.jsp, then client.jsp page is displayed. Now, let us see our client.jsp file as follows:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
    <%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Struts2 Action Example</title>
    </head>
       <body>
          <h1>Client Information</h1>
          <hr/>
          <a href="default.jsp">HOME</a>
          <br/> <br/> <br/>
          <b>Thanks You</b>
          <center>
             <table border="1">
                <tr>
                  <td>Name</td>
                  <td>Email</td>
                  <td>Address</td>
                <tr>
                  <td><s:property value="name"></s:property></td>
                  <td><s:property value="email"></s:property></td>
                  <td><s:property value="address"></s:property></td>
             </table>
           </center>
       </body>
</html>

Execute the Application

Finally, start Tomcat and try to access URL https://ecomputernotes.com:8080/Struts2_Action_Example/. This will give you following screen:

      Enter Client Information

Let us enter Name, Email and Address and you should see the following page:

      After Success Page Output

Now leaves any field empty and you should see the following Output:

      After Leaving Blank Field

Struts2 Vs Struts1

By Dinesh Thakur

Both versions of Struts hosting framework provide the following three key components:
• A request handler provided by the application developer that maps Java classes to standard URI.
• A response handler that maps control to server pages or other Web resources which then will be responsible for completing the response.
• A tag library that helps developers to creating rich, responsive, form-based applications with server pages.

Difference between Struts1 and Struts2

1. ACTION CLASS

In Struts 1 Action classes extend an abstract base class. A common problem in Struts 1 is use abstract classes instead of interfaces.

In Struts 2 Action class may implement an Action interface, with other interfaces to enable require services. Struts 2 provides a base ActionSuppport class to implement commonly used interfaces. The Action interface is not required. Any POJO object with a execute can be used as an Struts 2 Action object.

      ACTION CLASS

2. Threading Model

Struts1 Actions are singletons and must be thread- safe since there will only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. Action resources must be thread-safe or synchronized.

Struts2 Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containers generate many throw away objects per request, and one more object does not impose a performance penalty or impact garbage collection.)

      Threading Model

3. Servlet Dependency

In Struts1 the HttpServletRequest and HttpServlet Response is passed to the execute method when an Action is invoked as the as Actions have dependencies on the servlet API.

Struts2 Actions are not coupled to a container. Struts2 Actions can access the original request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServlet Response directly.

      Servlet Dependency

4. Expression Language

Struts1 integrates several tag libraries, so it uses the JSTL EL. The EL has basic object graph traversal, but relatively weak collection and indexed property support Tag libraries for JSP.

Struts2 can use JSTL single tag library that covers all, but the framework also supports a more powerful and flexible expression language called “Object Graph Notation Language” (OGNL) data transfer /type conversion.

      Expression Language

5. Binding Values into Views

Struts1 uses the standard JSP mechanism for binding objects into the page context for access.

Struts2 uses a “ValueStack” technology so that the taglibs can access values without coupling. The ValueStack technique allows reuse of views across a range of types which may have the same property name but different property types.

      Binding Values into Views

6. Crosscutting for Action Form

Struts1 uses an ActionForm object to handle the input like Actions, HTML form is mapped to an ActionForm instance, all ActionForms must extend a base class. Since other JavaBeans cannot be used as ActionForms, developers often create redundant classes to handle input.

Struts2 uses Action properties as input properties, eliminating the need for a second input object. Input properties may be rich object types which may have their own properties. The Action properties can be accessed from the web page via the taglibs. Struts2 also support the ActionForm pattern, as well as POJO form objects and POJO Actions. HTML form maps directly to a POJO. Rich object types, including business or domain objects, can be used as input/output objects.

      Crosscutting for Action Form

7. Control of Action Execution

Struts1 supports separate Request Processors or each module, but all the Actions in the module must share the same lifecycle.

Struts2 supports creating different lifecycles as per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed.

      Control of Action Execution

8. Type Conversion

Struts1 Action Form properties are usually all Strings. Struts1 use Commons-Beanutils for type conversion. Converters are per-class, and not configurable per instance.

Struts2 use OGNL for type conversion. The framework includes converters for basic and common object types and primitives.

Struts 2 Examples

By Dinesh Thakur

As you learn a user sends a request from its web browser which is in the form of a URL. The request sent by the user passes through a standard filter chain which actually collected by the Controller (Filter Dispatcher). Controller examines each incoming URL request and determines which action should handle the request. Then the Controller transfers the request to the action class. The action plays an important role in the transfer of data from the request through to the view. Finally, the Result renders the output to the Web browser that requested. [Read more…] about Struts 2 Examples

Struts 2 Framework Architecture

By Dinesh Thakur

Request Initialization {HTTPSERVLETREQUEST}

A user sends a request fromits web browser which is in the form of a URL and it represents an Action. The user’s request begins and ends in its web browser. The request sent by the user passes through a standard filter chain which actually makes the decision by calling the desired StrutsPrepareAndExecuteFilter. Its fully qualified name is org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.

FilterDispatcher was used instead of StrutsPrepareAndExecuteFilter in older Struts version 2.1.3

Struts 2 Servlet Filter {StrutsPrepareAndExecuteFilter}

StrutsPrepareAndExecuteFilter is the upgraded version or we use this in Struts 2.1 version. In Struts 2 the StrutsPrepareAndExecuteFilter plays the role of a controller. The preparation and execution phases of the Struts2 handle by StrutsPrepareAndExecuteFilter. This object is a servlet filter whose job is to inspect each incoming request and determine which action should handle the request. This Struts2 Servlet filter also consults the ActionMapper to determine if the request should refer to an Action or not. The framework handles all of the controller work and only needs to be informed about which request URL maps to which action. Then this information is passed to the framework using an XML configuration file i.e. struts.xml.

We use this filter rather than dispatch filter due to some reasons which are given below-:

• There were a number of issues that arise while using this FilterDispatcher and its deployment, new Filter offers a better way to enable customizations and overrides these issues.

• Make it crystal clear to developers which filters are doing which processes.

• Make dispatch process more flexible to support things like native operation in OSGL or plugin system.

         Struts Architecture

Action Mapper

The ActionMapper interface gives us a mapping between HTTP requests and action invocation requests and vice-versa. When we send an HttpServletRequest Action Mapper determines that an action should be invoked, then the StrutsPrepareAndExecuteFilter passes the control to the Action Proxy and if no action invocation request matches, then ActionMapper return null and it may return an ActionMapping which describes an action invocation for the framework to try.

The ActionMapper is not required to guarantee that the ActionMapping returned be a real action or otherwise it confirms a valid request. Accordingly, most ActionMappers do not require consulting the Struts configuration just to determine if a request should be mapped.

Just as requests can be mapped from HTTP to an action invocation, the reverse is true as well. However, because HTTP requests (when shown in HTTP responses) must be in a String format, a String is returned rather than an actual request object.

Action Proxy

The Action Proxy then consults the framework Configuration Files manager which again consults to struts.xml to determine whether any action is defined for the request and then processes the request and the execution results after the request has been processed.

Action Invocation

The Action Proxy creates an Actionlnvocation that is responsible for the command pattern implementation. Then the Actionlnvocation consults the configuration and creates an instance of Action and calls the interceptors and invokes the corresponding action. When the action returns, the Actionlnvocation looks for the corresponding result of the action in the struts.xml file and executes the result which may be JSP or templates.

Configuration Manager

The configuration files is the Web application Deployment Description or web.xml file. In Struts 2, this file plays an important role in the configuration of web application. This file gives full control to the developer for configuring Struts-based application. (When, by default Struts loads a set of internal configuration files to configure it, and then another set of configuration for configuration your application.)

The Configuration files that are used to configure an application in Struts 2 are as follows:-

web.xml

struts.xml

struts. properties

struts-default.xml

struts-plugin.xml

Struts allows dynamic reloading of XML configuration file, some configuration files can be reloaded dynamically. This dynamic reloading makes interactive development possible. Using dynamic reloading can reconfigure your action mapping of your application during development. But if you want to use this feature, you need to set struts.configuration.xml, reload copy of struts. properties file.

Actions

Actions are the core of the Struts 2 framework, as they are for any MVC (Model View Controller) framework. Each URL is mapped to a specific action, which provides the processing logic necessary to service the request from the user. This is an action-oriented framework

But the action also serves in two other important capacities.

The action plays an important role in the transfer of data from the request through to the view, whether it is a JSP or other type of result.

The action must assist the framework in determining which result should render the view that will be returned in the response to the request.

Optionally you can extend the ActionSupport class which implements six interfaces including Action interface. The Action interface is as follows

public interface Action {

public static final String SUCCESS= “success”;

public static final String NONE = “none”;

public static final String ERROR= “error”;

public static final String INPUT = “input”;

public static final String LOGIN = “login”;

public String execute() throws Exception;

}

we have to extend ActionSupport class which implements action interface, so we can use String constants SUCCESS and ERROR like this.

Role of action:

• Actions provide Encapsulation:

The role of this encapsulation is to hold the business logic. Actions are invoked by calling the execute() method.

• Action helps to carry data.

• Action returns control string.

Strengths of Struts Framework:

1. Validation:

  Before executing the business logic of an application, the Input values must be validated. If the input values are correct then the business logic of the application will be executed, otherwise the request will be rejected.

In order to validate the input values given by the client. we have both client side and server side validations. Using struts we have extensive support to perform validations on the input. Struts provides client side validation by without creating any JavaScript code.

2. Internationalization (I18N)

I18N means, it is a process of converting a content of an application into multiple languages according to the language the religion and the country.

In struts framework we have inbuilt support for I18N. It means without writing any additional code the framework convert the page content according to the browser.

3. Exception Handling:

  In an application, exception can arise at various places. if you want to manually handle them , then we need to put try catch block at various places.

Writing try and catch blocks at various places makes burder to the application developer. So in struts the framework will handle the exception that occurred at various places in an application and provide an error page back to the browser rather than printing exception.

MVC Architecture

By Dinesh Thakur

We call Model-2 architecture as MVC (Model View Controller) architecture but Model-1 has Model-1. There are three main components exists in Model 2 architecture: the model, the view, and the controller. Initially the term Model2 is used in the JavaServer Pages Specification version 0.92.

Model Layer

The Model layer is the most important part of the MVC paradigm.The Model is implemented by the Action component in Struts2. Model is used to implement all the application data and business logic of web based application or persistence logic. It represents the information of the application. Anything that an enterprise web application persists becomes a part of Model layer.  It is the work of Java developer to develop a model. There are different technologies available in Java to create a model.

1. Java Bean
2. Enterprise Java bean
3. Hibernate
4. Web services
5. EJB
6. Spring
In Struts 2, the model is implemented by the Action component.

View Layer

It is used to implement presentation logic of a web based application. The View layer queries the Model layer for its content and renders it.  View is the work of web designer to create a view component, like Button, Textfield etc. The view is independent and it remains same even if the Application Logic or Business Logic undergoes change. There are many technologies available to implement presentation logic. A View in Struts 2 can be:

1. HTML

2. JSP

3. Freemarker

4. Swing and many more..

Controller Layer

It is used to implement controlling logic or Integration Logic of a web based application. It defines the control flow and execution flow of a web application. Servlet is the only technology to implement controller in a web application. In Struts 2, the role of the controller is played by the StrutsPrepareAndExecuteDisptacher. Filter Dispatcher examines incoming request to determine the Action that will handle the request.

            MVC Architecture

Integration logic is the central logic of the web application which takes the request from client, passes then to model layer resources, gather the results from model layer resources and passes the results to view layer resources. This logic controls and monitors every activity in a web application execution. All interaction between the View layer and the Model layer is managed by the Controller.

In Model View Architecture we integrate all the 4 logic

1. Presentation Logic (View)

2. Business Logic

3. Application Logic and Data Logic (Model)

4. Controlling Logic (Controller)

In a single JSP or SERVLET any change in one logic can affect the other logic.

In MVC Architecture, a servlet acts as a controller and it performs the common operations for all requests like input verification, session management, security etc. We call the servlet as a controller because it knows the entire flow of the web application.

The Controller finds appropriate business logic component for the given request and it will set the data to that component we call that business logic component as a model. By depending on the logic name/Hint returned by the model, the controller selects an appropriate view component this view component get response data from the model and takes this and point to the client browser.

According to MVC Architecture, servlet is a controller, Model is a Bean and JSP is a view.

Advantages of MVC Architecture:

1. Complexity is reduced, because each component has specific logic.

2. We can modify one component, by without affecting the other component.

Rules to be follow while constructing MVC Application:

1. In a web application, there can be any number of model components and any number of view components but there must be a single controller (servlet). This type of controller we call as front Controller.

2. We cannot do the direct linking between two pages, if we directly link two pages we are violating MVC principal because according to MVC the control flow of an application should be maintained controller only.

3. According to MVC architecture model and view component should not talk each other directly. The communication from view to Model and model to view should be done through the intermediator as controller.

4. In MVC, each component should contain its specific logic, we can’t mix-up some other logic into that component.

Importance of MVC Application:

1. While developing web application is Real-time, if one developer wants to understand the flow created by another developer then the entire flow of the application should be maintained at a single place.

2. If an application, follows an MVC principal then it is very simple to increase an application or even decrease an application when it is needed or required.

3. The application implemented using MVC can support different types of client at runtime.

4. While using MVC, it is recommended that use servlet as a controller bean as model and JSP is as view.

Framework

By Dinesh Thakur

We can develop applications by without using any framework in java. But the application development is very slow and we can’t get any additional container provided services.

If we used framework then an application development is becomes faster and apart from container services we can get, additional services from the framework. So we used frameworks for the development of Real world Application.

What is Framework?

A framework collection of services i.e. develop based on core technologies having the ability to generate the common logics of application dynamically. Which can be reused across multiple applications? Based on other application specific logics given by programmer, which provide set of libraries and these libraries are used in order to make an application development faster. A library is nothing but a JAR file it is similar to zip file contains set of java classes.

Framework software simplifies the process of application development for programmer by reduce the overhead jobs such as capture user input or to generate drop down list boxes. It just focuses on the business logic and the presentation layer of the application.

Framework software provides abstraction layer on core technologies and simplifies the process of application development for programmers. Every framework software internally uses certain core technologies but it makes programmer not to worry about core technologies (nothing about abstract layer) while developing framework based software application.

If we develop MVC2 architecture based web application by taking servlet, JSP core technologies then all the logics of all the layers must be developed by the programmers manually from scratch level. If you develop same application by using struts framework then the controller layer indication logic will be generated dynamically and programmers just need to concentrate only on view layer, model layer logic development.

This improves the productivity of web application development.

Frameworks are divided into two types.

1. Non-invasive or Non Intrusive

2. Invasive

Non-invasive framework means it does not force a programmer, to extend and to implement their classes from any predefine class or an interface given by that framework. Invasive framework means it forces the programmer to extend or implement their classes from a predefine class or an interface given by that framework.

For example:

             Spring, Hibernate are Non-invasive frameworks.

             Where as struts is an invasive framework.

Rules to be followed by frameworks:

1. Every framework is non installable software.

2. Each framework contains a high-level object and it is responsible for creating the remaining low level objects.

3. Each framework application contains atleast on configuration file of the framework.

Struts 2 Overview

By Dinesh Thakur

Struts2, is an OpenSymphony WebWork framework, is an Open source project provides an abstraction layer on top of the existing technologies called as Servlet and JSP for creating of Java based Web applications based on the MVC design pattern. Struts 2 framework is nothing but implementation of MVC-2 model on JSP.

Struts 2 framework features:

1. POJO forms and POJO actions: In struts the ActionForms were an integral part of the framework i.e. for receiving any input from the user there has to be an ActionForms. ActionForms needed lots of coding and they were a pain. But in struts2 any POJO can be used to receive the form input and also acts as an action class.

2. Tag Support: Because of the form tags like the head tag, hidden tag, label tag etc. and the new improved tags like timepicker tag(instead of datepicker) the developer has to write less codes.

3. Integration: struts2 can be easily integrated with other frameworks that are spring, tiles etc.

4. Plugin Support: By using the plugins supported by struts2, the behavior of the struts2 can be enhanced and augmented.

5. Easy to modify tags: In struts2 tag mark ups can be modified by using free mark templates. And for doing this it does not require JSP or java knowledge instead basic HTML, XML knowledge is enough to modify the tags.

6. Template Support: struts2 supports templates for generating dynamic views and pages. Three built-in themes come with struts2: simple, xhtml, and css_xhtml. By default xhtml theme is used.

7. AJAX support: struts2 support Ajax technology (stands for Asynchronous JavaScript and XML). AJAX technology creating interactive web applications with the help of Java Script, HTML, CSS and XML.

8. Struct2 Support Expression Language for View: struts2 can use JSTL, but the framework also supports a more powerful and flexible expression language like JSP, XSLT, OGNL to create View pages.

9. Result Types:  Various types of Results are supported by srtuts2. These are Dispatcher Result, FreeMarker Result, Stream Result Chain Result, Redirect Result , HttpHeader Result,  Velocity Result, XSL Result ,Redirect Action Result, Tiles Result, PlainText Result.

10. Interceptors: The struts2 framework provides a very important feature known as “INTERCEPTOR” which can be used to control the request and response. Interceptor can be runned before and after the execution of an action.

11. Type Conversion: struts1 use Commons-Beanutils for type conversion. struts2 use OGNL for type conversion.

12. Multiple view option [JSP, velocity, Freemarker and XSLT]

13. Struts2 Classes are based on interface.

14. Struts2 use themes based tag libraries and Ajax tags.

15. In Struts2 you can get all the information about your web application as your action class, form bean and JSP page information are present in the struts.xml file so you don’t have to search for them.

16. Struts2 has inbuilt capabilities to check that the form values are in the required format or not and if the values are net in proper format then the form willautomatically display the error message.

17. Another important feature of struts2 is being an open source it is exposed to the developers which enables fast development and maintenance cycle.

18. It reduces the project development time and cost in developing the controller and view parts of the web application.

Primary Sidebar

Structs Tutorials

Structs Tutorials

  • Struts - MVC Architecture
  • Struts - Framework Architecture
  • Struts - Struts2 Vs Struts1
  • Struts - Examples
  • Struts - Actions
  • Struts - Overview
  • Struts - Framework

Other Links

  • Structs - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW