<div dir="ltr" style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/asf-logo.gif" width="640" height="78" border="0" /></div>
<p>Hi in this struts tutorial we will discuss about struts 2 tutorial covers all the topics of Struts 2 Framework with simplified examples. The struts framework was initially created by <b>Craig McClanahan</b> and donated to Apache Foundation in May, 2000 and Struts 1.0 was released in June 2001. The current stable release of Struts is struts-2.3.15 in GA / June 3, 2013.</p>
<h2>Struts Tutorial</h2>
<p>Lets&#8217;s see struts tutorial and below explained the topics.</p>
<h3><b>Struts 2 Framework</b></h3>
<p>Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to deploying, to maintaining applications over time. Apache Struts 2 was originally known as WebWork 2.</p>
<div style="background-color: #f2f9fc; border: 1px solid #c9e6f2; border-radius: 3px; padding: 16px; line-height: 1.45;">
<p><span style="color: red; font-size: x-large; text-align: center;"><b>Popular Tutorials</b></span></p>
<ul style="text-align: left;">
<li><b><a href="https://dineshonjava.com/spring-tutorial/"><em><strong>Spring Tutorial</strong> </em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-web-mvc-framework-chapter-38/"><strong><em>Spring MVC Web Tutorial </em></strong></a></b></li>
<li><b><a href="https://dineshonjava.com/introduction-to-spring-boot-a-spring-boot-complete-guide/"><strong>Spring Boot Tutorial</strong> </a></b></li>
<li><b><a href="https://dineshonjava.com/spring-security-take-baby-step-to-secure/"><em>Spring Security Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint/"><em>Spring AOP Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/using-spring-jdbc-framework-chapter-32/"><em>Spring JDBC Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-hateoas-hypermedia-driven-restful-web-service/"><em><strong>Spring HATEOAS </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/microservices-with-spring-boot/"><em><strong>Microservices with Spring Boot</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/jax-rs-web-service-tutorial/"><strong><em>REST Webservice</em> </strong></a></b></li>
<li><b><a href="https://dineshonjava.com/core-java-baby-step-to-be-best-java-ian/"><em><strong>Core Java </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/hibernate-3-on-baby-steps/"><em><strong>Hibernate Tutorial</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-batch-process-with-example/"><strong><em>Spring Batch</em> </strong></a></b></li>
</ul>
</div>
<p>The Struts 2 framework is used to develop MVC (Model View Controller) based web applications. Struts 2 is the combination of webwork framework of opensymphony and struts1.<br />
<i><b><br />
</b></i> <i><b>struts2 = webwork + struts1</b></i></p>
<p>The Struts 2 provides supports to POJO based actions, Validation Support, AJAX Support, Integration support to various frameworks such as Hibernate, Spring, Tiles etc, support to various result types such as Freemarker, Velocity, JSP etc. Struts2 is based on the Web works framework of OpenSymphony.</p>
<h3><b>Struts 2 Features </b></h3>
<p>The strut-2 framework is designed for the compilation of the entire development cycle including of building, developing and maintaining the whole application. It is very extensible as each class of the framework is based on an Interface and all the base classes are given an extra application and even you can add your own. The basic platform requirements are Servlet API 2.4, JSP API 2.0 and Java 5.</p>
<ul>
<li><b>Configurable MVC components</b> In struts 2 framework, we provide all the components (view components and action) information in struts.xml file. If we need to change any information, we can simply change it in the xml file.</li>
<li><b>POJO based actions</b> In struts 2, action class is POJO (Plain Old Java Object) i.e. a simple java class.</li>
<li><b>AJAX support</b> Struts 2 provides support to ajax technology. So a part of the page will be changed only and page will not reload. So it makes the performace fast.</li>
<li><b>Integration Support</b> We can simply integrate the struts 2 application with hibernate, spring, tiles etc. frameworks.</li>
<li><b>Various Result Types</b> We can use JSP, freemarker, velocity etc. technology as the result in struts2.</li>
</ul>
<h3><i><b>About Struts 2 Framework</b></i></h3>
<ul>
<li>Struts 2 is based on the <b>OpenSymphony </b>Web Works Framework.</li>
<li>Struts 2 framework implements the <b>Model-View-Controller (MVC)</b> design pattern.</li>
<li>In Struts 2 the <b>model, view and controller are implemented by the <i>action</i>, <i>result </i>and <i>FilterDispatcher </i>respectively.</b></li>
<li>The <b>controller</b>&#8216;s job is to map the user request to appropriate action.</li>
<li>In Struts 2 <b>FilterDispatcher </b>does the job of Controller.</li>
<li><b>Model </b>contains the data and the business logic.</li>
<li>In Struts 2 the model is implemented by the <b>Action </b>component.</li>
<li><b>View </b>is the presentation component of the MVC Pattern.</li>
<li>In <b>Struts 2</b> the view is commonly implemented using <b>JSP, Velocity Template, Freemaker </b>or some other presentation-layer technology.</li>
</ul>
<h3><i><b>About Struts 2 Request Flow</b></i></h3>
<ol>
<li>The <b>controller </b>receives the user request and determine which Struts 2 <b>action </b>to invoke.</li>
<li>The framework creates an instance of this action and associate it with the newly created instance of the <b>ActionInvocation</b>.</li>
<li>In Struts 2 the invocation of action should pass through a series of interceptors as defined in the application&#8217;s XML file.</li>
<li>The framework calls the <b>ActionInvocations <i>invoke()</i></b> method to start the execution of the action.</li>
<li>Each time the<i><b> invoke() </b></i>method is called, <b>ActionInvocation </b>consults its state and executes whichever interceptor comes next.</li>
<li><b>ActionInvocation </b>hands control over to the interceptor in the stack by calling the interceptors <i><b>intercept() </b></i>method.</li>
<li>The<i><b> intercept()</b></i> method of the interceptor intern calls the<i><b> invoke() </b></i>method of the <b>ActionInvocation </b>till all the interceptors are invoked, in the end the action itself will be called and the corresponding result will be returned back to the user.</li>
<li>Some <b>interceptor </b>do work before the action is executed and some do work after the action is executed. It&#8217;s not necessary that it should do something each time it is invoked.</li>
<li>These <b>interceptors </b>are invoke both before and after the <b>action</b>.</li>
<li><b>First all the interceptors are executed in the order they are defined in the stack</b>.</li>
<li>Then the action is invoked and the result is generated.</li>
<li>Again all the interceptors present in the stack are invoked in the reverse order.</li>
<li>The other important features of<b> Struts 2</b> are <b>OGNL </b>and <b>ValueStack</b>.</li>
<li><b>Object-Graph Navigation Language (OGNL)</b> is a powerful expression language that is used to reference and manipulate data on the <b>ValueStack</b>.</li>
<li><b>OGNL </b>help in data transfer and type conversion.</li>
<li><b>OGNL </b>expression language provides simplified syntax to reference java objects.</li>
<li><b>OGNL </b>is used to bind the java-side data properties to the string-based view layer.</li>
</ol>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/Struts2-Architecture-1.png" border="0" /></div>
<h3><i><b>Architecture of Struts 2 Framework</b></i></h3>
<ul>
<li>In Struts 2 the action resides on the <b>ValueStack </b>which is a part of the <b>ActionContext</b>. <b>ActionContext </b>is a global storage area that holds all the data associated with the processing of a request.</li>
<li>When a request comes the <b>params </b>interceptor helps in moving the request data to the <b>ValueStack</b>.</li>
<li>Now the <b>OGNL </b>does the job of converting the string based form data to their corresponding java types. <b>OGNL </b>does this by using the set of available built-in type converters.</li>
<li>Again when the results are generated the <b>OGNL </b>converts the java types of the property on the <b>ValueStack </b>to the string-based HTML output.</li>
<li><b>ActionContext </b>is thread local which means that the values stored in the <b>ActionContext </b>are unique per thread, this makes the Struts 2 actions thread safe.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/ValueStackPic1.gif" border="0" /></div>
<h3>Struts Tutorial Contents</h3>
<p><b><i>Struts Tutorial : 2 Basic</i></b><br />
<b>1 &#8211; <a href="https://dineshonjava.com/2013/07/introduction-to-mvc.html" target="_blank" rel="noopener">Introduction To MVC</a></b><br />
<b>2 &#8211; <a href="https://dineshonjava.com/2013/07/model-1-and-model-2-mvc-architecture.html" target="_blank" rel="noopener">Model 1 and Model 2(MVC)</a> </b><br />
<b>3 &#8211; <a href="https://dineshonjava.com/2013/07/introduction-to-struts-2-framework.html" target="_blank" rel="noopener">Introduction to Struts 2</a></b><br />
<b>4 &#8211; <a href="https://dineshonjava.com/2013/07/architecture-of-struts-2-framework.html" target="_blank" rel="noopener">Architecture of Struts 2</a> </b><br />
<b>5 &#8211; <a href="https://dineshonjava.com/2013/07/setting-up-struts-2-in-eclipse.html" target="_blank" rel="noopener">Setting Up Struts 2 in Eclipse</a></b><br />
<b>6 &#8211; <a href="https://dineshonjava.com/2013/07/writing-struts-2-hello-world-application.html" target="_blank" rel="noopener">Writing a Struts 2 Hello World Application</a></b><br />
<b>7 &#8211; </b><b><a class="GIL3GQOBOB" href="https://dineshonjava.com/2013/07/struts-2-ognl.html#.UfOGK22ktH1" target="_blank" rel="noopener">Struts 2 OGNL, ActionInvocation, ActionContex</a> </b><br />
<b>8 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-configuration-file.html" target="_blank" rel="noopener">Configuration of Struts 2</a> </b><br />
<b>9 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-namespace-configuration-example.html" target="_blank" rel="noopener">Understanding Namespaces</a></b><br />
<b>10 &#8211; <a href="https://dineshonjava.com/2013/07/a-tag-and-business-service.html" target="_blank" rel="noopener">A Tag And A Business Service</a></b><br />
<b>11 &#8211; <a href="https://dineshonjava.com/2013/07/the-valuestack-in-struts-2.html" target="_blank" rel="noopener">The ValueStack in Struts 2</a></b><br />
<b>12 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-actions.html" target="_blank" rel="noopener">Struts 2 Actions</a></b><br />
<b>13 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-interceptors.html" target="_blank" rel="noopener">Struts 2 Interceptors</a></b><br />
<b>14 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-result-types.html" target="_blank" rel="noopener">Struts 2 Result Types</a></b><br />
<b>15 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-file-upload-example.html" target="_blank" rel="noopener">Struts 2 File Uploads</a></b><br />
<b>16 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-database-access.html" target="_blank" rel="noopener">Struts 2 Database Access</a></b><br />
<b>17 &#8211; <a href="https://dineshonjava.com/2013/07/struts-2-sending-mails.html" target="_blank" rel="noopener">Struts 2 Sending Mails</a></b><br />
<b>18 &#8211; <a href="https://dineshonjava.com/2013/07/struts2-validation-with-example.html" target="_blank" rel="noopener">Struts 2 Validations</a></b><br />
<b>19 &#8211; <a href="https://dineshonjava.com/2013/08/localization-i18n-in-struts2.html" target="_blank" rel="noopener">Struts 2 Localization</a></b><br />
<b>20 &#8211; <a href="https://dineshonjava.com/2013/08/themes-in-struts-2.html" target="_blank" rel="noopener">Struts 2 Themes/Templates</a></b><b> </b><br />
<b>21 &#8211; <a href="https://dineshonjava.com/2013/08/struts-2-exception-handling.html" target="_blank" rel="noopener">Struts 2 Exception Handling</a></b><br />
<b>22 &#8211; <a href="https://dineshonjava.com/2013/08/annotations-in-struts2-with-example.html" target="_blank" rel="noopener">Struts 2 Annotations</a></b><br />
<b><i>Struts Tutorial : </i></b><i><b>Struts 2 Tags</b></i><br />
<b>1 &#8211; <a href="https://dineshonjava.com/2013/08/struts-2-control-tags.html" target="_blank" rel="noopener">Struts 2 Control Tags</a></b><br />
<b>2 &#8211; <a href="https://dineshonjava.com/2013/08/struts-2-data-tags.html" target="_blank" rel="noopener">Struts 2 Data Tags</a></b><br />
<b>3 &#8211; <a href="https://dineshonjava.com/2013/08/the-form-tags-in-struts2.html" target="_blank" rel="noopener">Struts 2 Form Tags</a></b><br />
<b>4 &#8211; <a href="https://dineshonjava.com/2013/08/struts-2-ajax-tags-example.html" target="_blank" rel="noopener">Struts 2 Ajax Tags</a></b><br />
<b><i>Struts Tutorial : </i></b><i><b>Struts 2 Integrations</b></i><br />
<b>1 &#8211; <a href="https://dineshonjava.com/2013/08/struts2-spring-3-integration-example.html" target="_blank" rel="noopener">Struts 2 with Spring 3 Integration</a></b><br />
<b>2 &#8211; <a href="https://dineshonjava.com/2013/08/struts2-integration-with-tiles2-spring3.html" target="_blank" rel="noopener">Struts 2 with Tiles 2 Spring 3 Integration</a></b><br />
<b>3 &#8211; <a href="https://dineshonjava.com/2013/08/struts-2-hibernate-3-integration.html" target="_blank" rel="noopener">Struts 2 with Hibernate 3 Spring3 Tiles 2 Integration</a></b><br />
<b>4 &#8211; <a class="GHUY-LPOB" href="https://dineshonjava.com/2013/08/struts-2-and-json-example.html#.UhebMj9jxH0" target="_blank" rel="noopener">Struts 2 And JSON Example</a></b><br />
<b><br />
</b></p>
<p><b><i>Struts Tutorial </i>References</b></p>
<h3 class="r"><a href="http://struts.apache.org/release/2.3.x/" target="_blank" rel="noopener"><i>Struts 2</i> &#8211; Welcome</a></h3>
<h3 class="r"><a href="http://en.wikipedia.org/wiki/Apache_Struts" target="_blank" rel="noopener">Struts 2 -Wiki </a></h3>
<h3 class="r"></h3>
<h3 class="r"></h3>
<h3 class="r"></h3>
<h3 class="r"></h3>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/introduction-to-mvc/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '406'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…