<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Struts &#8211; Jitendra Zaa</title>
	<atom:link href="https://www.jitendrazaa.com/blog/category/java/struts/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Wed, 30 Mar 2011 07:21:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">87744916</site><atom:link rel="search" type="application/opensearchdescription+xml" title="Search Jitendra Zaa" href="https://www.jitendrazaa.com/blog/wp-json/opensearch/1.1/document" />	<item>
		<title>Explain dynamic method invocation in Struts 2</title>
		<link>https://www.jitendrazaa.com/blog/java/struts/explain-dynamic-method-invocation-in-struts-2/</link>
					<comments>https://www.jitendrazaa.com/blog/java/struts/explain-dynamic-method-invocation-in-struts-2/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Wed, 30 Mar 2011 07:21:18 +0000</pubDate>
				<category><![CDATA[Struts]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1864</guid>

					<description><![CDATA[Explain dynamic method invocation in Struts 2]]></description>
										<content:encoded><![CDATA[<p>Dynamic Method invocation is the concept in the Struts action mapping file, where instead of writing &lt;action&gt; for every method, one can map the wild character with the method name having same prefix or suffix.</p>
<p>Example : Instead of writing addOperation, subOperation and divOperation, programmer can write *Operation.</p>
<p>Consider below jsp code:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;s:form action=&quot;calculator_add&quot; &gt;
&lt;s:textfield name=&quot;num1&quot; label=&quot;Number 1&quot;&gt;&lt;/s:textfield&gt;
&lt;s:textfield name=&quot;num2&quot; label=&quot;Number 2&quot;&gt;&lt;/s:textfield&gt;
&lt;s:submit action=&quot;calculator_add&quot; value=&quot;Add&quot; /&gt;
&lt;s:submit action=&quot;calculator_sub&quot; value=&quot;Substract&quot; /&gt;
&lt;/s:form&gt;
</pre>
<p><span id="more-1864"></span>Struts configuration:</p>
<pre class="brush: xml; highlight: [10,11,12,13]; title: ; notranslate">
&lt;package name=&quot;calc&quot; extends=&quot;struts-default&quot;&gt;
		&lt;action name=&quot;calculatorInput&quot;&gt;
			&lt;result&gt;/pages/calculator.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;calculatorResult&quot;&gt;
			&lt;result&gt;/pages/calculatorResult.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;calculator_*&quot; method=&quot;{1}&quot;
			class=&quot;com.G2.Actions.CalculatorAction&quot;&gt;
			&lt;result name=&quot;success&quot; type=&quot;chain&quot;&gt;calculatorResult&lt;/result&gt;
		&lt;/action&gt;

	&lt;/package&gt;
</pre>
<p>As you can see, instead of writing different action, action name is provided like &#8220;calculator_*&#8221;,  and method=&#8221;{1}&#8221;, means if the input is &#8220;calculator_add&#8221; then the add() method will be executed in Action class. That means we can invoke any methods dynamically other than execute() in action class.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/java/struts/explain-dynamic-method-invocation-in-struts-2/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1864</post-id>	</item>
		<item>
		<title>Error Resolved- Form action defaulting to &#8216;action&#8217; attribute&#8217;s literal value</title>
		<link>https://www.jitendrazaa.com/blog/java/struts/error-resolved-form-action-defaulting-to-action-attributes-literal-value/</link>
					<comments>https://www.jitendrazaa.com/blog/java/struts/error-resolved-form-action-defaulting-to-action-attributes-literal-value/#respond</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Wed, 30 Mar 2011 06:59:00 +0000</pubDate>
				<category><![CDATA[Struts]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1860</guid>

					<description><![CDATA[Error Resolved in Struts 2- Form action defaulting to 'action' attribute's literal value]]></description>
										<content:encoded><![CDATA[<p>This Error normally comes while using <strong><a title="Dynamic Method Invocation" href="https://jitendrazaa.com/blog/java/struts/explain-dynamic-method-invocation-in-struts-2/" target="_blank">Dynamic Method invocation</a></strong> of Struts 2.<br />
Consider below code:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;s:form &gt;
&lt;s:textfield name=&quot;num1&quot; label=&quot;Number 1&quot;&gt;&lt;/s:textfield&gt;
&lt;s:textfield name=&quot;num2&quot; label=&quot;Number 2&quot;&gt;&lt;/s:textfield&gt;
&lt;s:submit action=&quot;calculator_add&quot; value=&quot;Add&quot; /&gt;
&lt;s:submit action=&quot;calculator_sub&quot; value=&quot;Substract&quot; /&gt;
&lt;/s:form&gt;
</pre>
<p>In Above example, two action methods are called in a single form.<span id="more-1860"></span></p>
<p>Let&#8217;s say configuration file contains below setting:</p>
<pre class="brush: xml; highlight: [17,18,19,20]; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
        &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
        &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

	&lt;package name=&quot;calc&quot; extends=&quot;struts-default&quot;&gt;
		&lt;action name=&quot;calculatorInput&quot;&gt;
			&lt;result&gt;/pages/calculator.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;calculatorResult&quot;&gt;
			&lt;result&gt;/pages/calculatorResult.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;calculator_*&quot; method=&quot;{1}&quot;
			class=&quot;com.G2.Actions.CalculatorAction&quot;&gt;
			&lt;result name=&quot;success&quot; type=&quot;chain&quot;&gt;calculatorResult&lt;/result&gt;
		&lt;/action&gt;

	&lt;/package&gt;
&lt;/struts&gt;
</pre>
<p>If we try to access the page via action like &#8220;http://localhost:8080/DynamicMethodInvocation/calculatorInput.action&#8221;<br />
Then the code runs fine.</p>
<p>When we try to access the same page directly:<br />
&#8220;http://localhost:8080/DynamicMethodInvocation/pages/calculator.jsp&#8221;<br />
Boom !!!  we got error <strong>&#8220;Form action defaulting to &#8216;action&#8217; attribute&#8217;s literal value&#8221;</strong>.</p>
<p>If you observe the jsp code clearly, you can see that there is no action attribute is set in the tag &lt;s:form&gt;.<br />
So, to overcome this problem, <strong>we must specify the default action in &lt;s:form&gt;.</strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/java/struts/error-resolved-form-action-defaulting-to-action-attributes-literal-value/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1860</post-id>	</item>
		<item>
		<title>Dynamic Results in Struts 2</title>
		<link>https://www.jitendrazaa.com/blog/java/struts/dynamic-results-in-struts-2/</link>
					<comments>https://www.jitendrazaa.com/blog/java/struts/dynamic-results-in-struts-2/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Wed, 30 Mar 2011 06:29:02 +0000</pubDate>
				<category><![CDATA[Struts]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1851</guid>

					<description><![CDATA[Example and sourcecode of creating Dynamic Results in Struts 2]]></description>
										<content:encoded><![CDATA[<p>In Struts 2, we can decide next action to be executed at runtime with complete set of its own interceptors.  here <a title="Struts 2 login application example and sourcecode" href="https://jitendrazaa.com/blog/java/struts/step-by-step-simple-login-application-in-struts-2/" target="_blank"> i will assume the example and source code of the previous article.</a></p>
<p>For this demo, change the existing Action class code:<br />
<span id="more-1851"></span></p>
<pre class="brush: java; highlight: [20,23,24,25,27,28,29]; title: ; notranslate">
package com.G2.Actions;

import com.G2.Model.LoginValidate;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

	String uName,pwd;
	String nextAction;

	@Override
	public String execute() throws Exception {
		boolean res = LoginValidate.isLoginValid(uName, pwd);

		if(res)
			nextAction = &quot;LoginSuccess&quot;;
		else
			nextAction = &quot;LoginInput&quot;;

		return  &quot;next&quot;;
	}

	public String getNextAction() {
		return nextAction;
	}

	public void setNextAction(String nextAction) {
		this.nextAction = nextAction;
	}

	public String getuName() {
		return uName;
	}

	public void setuName(String uName) {
		this.uName = uName;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
}
</pre>
<p>As you can see, I have added one more filed with setters and getters named &#8220;nextAction&#8221;, which will be accessed in struts configuration file.</p>
<p>Change in Configuration file :</p>
<pre class="brush: xml; highlight: [18]; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
        &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
        &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

	&lt;package name=&quot;Login&quot; extends=&quot;struts-default&quot;&gt;
		&lt;action name=&quot;LoginInput&quot;&gt;
			&lt;result&gt;/pages/Login.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;LoginSuccess&quot;&gt;
			&lt;result &gt;/pages/LoginSuccess.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;LoginAction&quot; class=&quot;com.G2.Actions.LoginAction&quot;&gt;
			&lt;result name=&quot;next&quot; type=&quot;redirectAction&quot;&gt;${nextAction}&lt;/result&gt;
		&lt;/action&gt;

	&lt;/package&gt;
&lt;/struts&gt;


</pre>
<p>Here we are redirecting, on the next action if the result name is &#8220;next&#8221;. The next action is decided by the variable &#8220;nextAction&#8221; of the Action class. In above configuration if we change the result type to &#8220;chain&#8221; instead of &#8220;redirectAction&#8221;, then still application will run.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/java/struts/dynamic-results-in-struts-2/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1851</post-id>	</item>
		<item>
		<title>Step by Step Simple Login Application in Struts 2</title>
		<link>https://www.jitendrazaa.com/blog/java/struts/step-by-step-simple-login-application-in-struts-2/</link>
					<comments>https://www.jitendrazaa.com/blog/java/struts/step-by-step-simple-login-application-in-struts-2/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Thu, 24 Mar 2011 13:23:33 +0000</pubDate>
				<category><![CDATA[Struts]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1834</guid>

					<description><![CDATA[Example of Simple Login Application in Struts 2]]></description>
										<content:encoded><![CDATA[<p><a title="What is struts and how it works" href="https://jitendrazaa.com/blog/java/struts/what-is-struts-2-and-how-it-works/" target="_blank">We have seen that what is struts and how it works. </a>I will guide the new developer, step by step to create the login application using struts 2 in this article.</p>
<p><strong>Step 1 : </strong><a title="Download Struts jar file" href="http://struts.apache.org/download.cgi" target="_blank">Download the struts jar file </a>or sample application from the official struts website.</p>
<p><strong>Step 2 :</strong> Create a web project for jsp and open web.xml. In web.xml add the following lines of code in between &lt;web-app&gt; tag.</p>
<pre class="brush: xml; title: ; notranslate">

    &lt;filter&gt;
	&lt;filter-name&gt;webwork&lt;/filter-name&gt;
	&lt;filter-class&gt;
	    org.apache.struts.action2.dispatcher.FilterDispatcher
	&lt;/filter-class&gt;
    &lt;/filter&gt;

    &lt;filter-mapping&gt;
	&lt;filter-name&gt;webwork&lt;/filter-name&gt;
	&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;

</pre>
<p><span id="more-1834"></span><br />
Above configuration declares <strong>FilterDispatcher </strong>for struts 2 which is boot strap component for your website.</p>
<p><strong>Step 3 :</strong> Copy all the jar files of struts 2 application downloaded in Step 1 into lib folder of your application.</p>
<p><strong>Step 4 : </strong>Create<strong> struts.xml</strong> file at the root level of the classes and add following lines :</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
    &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
    &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

    &lt;constant name=&quot;struts.enable.DynamicMethodInvocation&quot; value=&quot;false&quot; /&gt;
    &lt;constant name=&quot;struts.devMode&quot; value=&quot;false&quot; /&gt;

    &lt;include file=&quot;Login.xml&quot;/&gt;

&lt;/struts&gt;
</pre>
<p>As you can see in above configuration, I have included other configuration file named &#8220;Login.xml&#8221; Instead of writing all the configuration in single struts.xml , we can split the xml configuration file and include in main struts.xml. I will explain the creation of file &#8220;Login.xml&#8221; later in this tutorail series.</p>
<p><strong> Step 5 : </strong>Now create a jsp page in folder &#8220;pages&#8221; under WebContent folder with Name &#8220;Login.jsp&#8221;.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
&lt;title&gt;Login&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=&quot;LoginAction.action&quot; &gt;
UserName : &lt;input type=&quot;text&quot; name=&quot;uName&quot; /&gt;&lt;br/&gt;
Password : &lt;input type=&quot;password&quot; name=&quot;pwd&quot; /&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot;&gt;&lt;/input&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong>Step 6 :</strong> Create one <strong>Model Class</strong>, where the logic is written to validate the User. Here in this series no database is envolved. We have simply hardcoaded the tutorial for easy understanding of the concept.</p>
<pre class="brush: java; title: ; notranslate">
package com.G2.Model;

public class LoginValidate {

	public static boolean isLoginValid(String uName, String pwd)
	{
		return &quot;admin&quot;.equals(uName) &amp;&amp; &quot;admin&quot;.equals(pwd)?true:false;
	}
}
</pre>
<p><strong>Step 7: </strong>Now create the Action Class.</p>
<pre class="brush: java; title: ; notranslate">
package com.G2.Actions;

import com.G2.Model.LoginValidate;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

	String uName,pwd;

	public String getuName() {
		return uName;
	}

	public void setuName(String uName) {
		this.uName = uName;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	@Override
	public String execute() throws Exception {
		return LoginValidate.isLoginValid(uName, pwd) ? SUCCESS : INPUT;
	}

}
</pre>
<p><strong>Points to remember while creating Action classes in Struts 2:</strong></p>
<ol>
<li>Every Action Class extend the Class &#8220;<strong>com.opensymphony.xwork2.ActionSupport</strong>&#8220;.</li>
<li>override the execute() method.</li>
<li>There is no compulsion on extending the ActionSupport class, and not necessary that only execute() method works. Any method, which return string can work. That&#8217;s the powerful feature of new Struts 2 framework. <strong>But if we will not extend &#8220;ActionSupport&#8221;, then we will miss much of the default capabilities of Struts like Validation features.</strong></li>
<li>V<strong>ariable name must be same as expected request parameter name with getter and setters</strong>. In this case we expect two request parameter named uName and pwd.</li>
<li>Any String result can be returned from execute() method of the struts2, but it is recommended to return the standard defined result like SUCCESS or INPUT.</li>
</ol>
<p><strong>Step 8: </strong>Create configuration file which is included in step 4 of name &#8220;Login.xml&#8221;. Instead of creating this file, we may also add the code lines in struts.xml, but it is good practice to have the separate xml file of separate modules in application.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
        &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
        &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

    &lt;package name=&quot;Login&quot; extends=&quot;struts-default&quot;&gt;

        &lt;action name=&quot;LoginAction&quot; class=&quot;com.G2.Actions.LoginAction&quot;&gt;
            &lt;result name=&quot;input&quot;&gt;/pages/Login.jsp&lt;/result&gt;
            &lt;result name=&quot;success&quot;&gt;/pages/LoginSuccess.jsp&lt;/result&gt;
        &lt;/action&gt;

    &lt;/package&gt;
&lt;/struts&gt;

</pre>
<p>Package in Java used to group together similar type of class. In struts 2, package tag is used to group together similar types of actions along with interceptors.<br />
The action &#8220;LoginAction&#8221;, may return <strong>two types of result, either &#8220;input&#8221; or &#8220;success&#8221;</strong>, depending on that the view is decided.</p>
<p>Instead of writing &#8220;jsp file path&#8221; in &lt;result&gt; , it is recommended to write the action, so that in future, if the page name changes then instead of changing jsp file path everywhere, we have to change only tag.<br />
So, the above configuration can be re-written as:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
        &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
        &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

	&lt;package name=&quot;Login&quot; extends=&quot;struts-default&quot;&gt;
		&lt;action name=&quot;LoginInput&quot;&gt;
			&lt;result&gt;/pages/Login.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;LoginSuccess&quot;&gt;
			&lt;result&gt;/pages/LoginSuccess.jsp&lt;/result&gt;
		&lt;/action&gt;

		&lt;action name=&quot;LoginAction&quot; class=&quot;com.G2.Actions.LoginAction&quot;&gt;
			&lt;result name=&quot;input&quot; type=&quot;chain&quot;&gt;LoginInput&lt;/result&gt;
			&lt;result name=&quot;success&quot; type=&quot;chain&quot;&gt;LoginSuccess&lt;/result&gt;
		&lt;/action&gt;

	&lt;/package&gt;
&lt;/struts&gt;

</pre>
<p>Note here, &#8220;<strong>type</strong>&#8220; attribute is introduced. There are many result types available in struts.</p>
<p>Mostly used types are: <strong>chain, redirect and dispatcher</strong></p>
<p><strong>Difference in &#8220;chain&#8221; and &#8220;redirectAction&#8221;</strong></p>
<p>In &#8220;Chain&#8221; result type, the next action class gets request object with all the parameters of the previous actions class whereas in &#8220;redirectAction&#8221;, new request is generated and therefore next Action class will not get the previous request and its parameters.</p>
<p>All available types can be read from: <a title="Result Types in Struts 2" href="http://struts.apache.org/2.x/docs/result-types.html" target="_blank">http://struts.apache.org/2.x/docs/result-types.html</a><br />
Final application structure is:</p>
<figure id="attachment_1835" aria-describedby="caption-attachment-1835" style="width: 252px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2011/03/Final-Structure-of-Struts-2-login-application.jpg?ssl=1"><img data-recalc-dims="1" fetchpriority="high" decoding="async" class="size-full wp-image-1835" title="Final Structure of Struts 2 login application" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2011/03/Final-Structure-of-Struts-2-login-application.jpg?resize=252%2C367&#038;ssl=1" alt="Final Structure of Struts 2 login application" width="252" height="367" /></a><figcaption id="caption-attachment-1835" class="wp-caption-text">Final Structure of Struts 2 login application</figcaption></figure>
<p><strong><a href="https://jitendrazaa.com/blog/wp-content/uploads/2011/03/struts2-Login.zip">Download War file of Source code (Change extension from zip to war)</a></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/java/struts/step-by-step-simple-login-application-in-struts-2/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1834</post-id>	</item>
		<item>
		<title>What is Struts 2 and how it works</title>
		<link>https://www.jitendrazaa.com/blog/java/struts/what-is-struts-2-and-how-it-works/</link>
					<comments>https://www.jitendrazaa.com/blog/java/struts/what-is-struts-2-and-how-it-works/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Thu, 24 Mar 2011 12:10:52 +0000</pubDate>
				<category><![CDATA[Struts]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1829</guid>

					<description><![CDATA[What is Struts 2 and how it works?]]></description>
										<content:encoded><![CDATA[<p>Struts 2 is the<strong> Open source web application Framework</strong> which simplified the creation of Web Applications in in Java. It is based on the <strong>Model – View – Framework (MVC)</strong> architect which is originally found in language &#8220;<strong>SmallTalk</strong>&#8220;.  Latest version of Struts is 2 and which is created by using concepts of <strong>WebWork and Xwork</strong>.</p>
<p><strong>Flow of Struts 2:</strong></p>
<figure id="attachment_1830" aria-describedby="caption-attachment-1830" style="width: 440px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2011/03/How-Struts-2-Works.jpg?ssl=1"><img data-recalc-dims="1" decoding="async" class="size-full wp-image-1830 " title="How Struts 2 Works" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2011/03/How-Struts-2-Works.jpg?resize=440%2C156&#038;ssl=1" alt="How Struts 2 Works" width="440" height="156" /></a><figcaption id="caption-attachment-1830" class="wp-caption-text">How Struts 2 Works</figcaption></figure>
<p><span id="more-1829"></span></p>
<p>&nbsp;</p>
<ol>
<li><strong>Request :</strong> Client makes the request.</li>
<li><strong>Filter Dispatcher : </strong>As Boot Strap component is specified in Deployment Descriptor file. In Case of Struts 2, it is <strong>Servlet Filter (Filter Dispatcher)</strong>. Filter Dispatcher looks the request and then as per the mapping of URL, request is forwarded to  appropriate Action Class.</li>
<li><strong>Interceptor Stacks :</strong> Before going to Action Class, request goes to Interceptor Stacks (Action class mapping found in configuration file, and from there, list of interceptors identified which must be processed before Action class) .</li>
<li><strong>Action Class : </strong>Then the request object is passed to Action Class. Action Class then executes the code and after execution it returns the result code to the Controller. (either SUCCESS or INPUT or ERROR)</li>
<li><strong>Result : </strong>On the basis of result code, Controller then selects View to be rendered as a result of Action.</li>
<li><strong>Interceptors Stack : </strong>Before sending response back to client, again interceptors run.</li>
<li>Response returned to User.</li>
</ol>
<p><strong>Note: If interceptor changes the result return type then the view will be changed and decided after interceptor.</strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/java/struts/what-is-struts-2-and-how-it-works/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1829</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-05-16 17:07:22 by W3 Total Cache
-->