{"id":1829,"date":"2011-03-24T17:40:52","date_gmt":"2011-03-24T12:10:52","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=1829"},"modified":"2011-03-24T17:40:52","modified_gmt":"2011-03-24T12:10:52","slug":"what-is-struts-2-and-how-it-works","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/what-is-struts-2-and-how-it-works\/","title":{"rendered":"What is Struts 2 and how it works"},"content":{"rendered":"<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 \u2013 View \u2013 Framework (MVC)<\/strong> architect which is originally found in language &#8220;<strong>SmallTalk<\/strong>&#8220;\u009d. \u00a0Latest version of Struts is 2 and which is created by using concepts of <strong>WebWork and Xwork<\/strong>.<\/p>\n<p><strong>Flow of Struts 2:<\/strong><\/p>\n<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\" loading=\"lazy\" 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>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><strong>Request :<\/strong> Client makes the request.<\/li>\n<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>\n<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>\n<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>\n<li><strong>Result : <\/strong>On the basis of result code, Controller then selects View to be rendered as a result of Action.<\/li>\n<li><strong>Interceptors Stack : <\/strong>Before sending response back to client, again interceptors run.<\/li>\n<li>Response returned to User.<\/li>\n<\/ol>\n<p><strong>Note: If interceptor changes the result return type then the view will be changed and decided after interceptor.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Struts 2 and how it works?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[16],"tags":[335],"class_list":["post-1829","post","type-post","status-publish","format-standard","hentry","category-struts","tag-struts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1834,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/step-by-step-simple-login-application-in-struts-2\/","url_meta":{"origin":1829,"position":0},"title":"Step by Step Simple Login Application in Struts 2","author":"Jitendra","date":"March 24, 2011","format":false,"excerpt":"Example of Simple Login Application in Struts 2","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"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=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1851,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/dynamic-results-in-struts-2\/","url_meta":{"origin":1829,"position":1},"title":"Dynamic Results in Struts 2","author":"Jitendra","date":"March 30, 2011","format":false,"excerpt":"Example and sourcecode of creating Dynamic Results in Struts 2","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1864,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/explain-dynamic-method-invocation-in-struts-2\/","url_meta":{"origin":1829,"position":2},"title":"Explain dynamic method invocation in Struts 2","author":"Jitendra","date":"March 30, 2011","format":false,"excerpt":"Explain dynamic method invocation in Struts 2","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1860,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/error-resolved-form-action-defaulting-to-action-attributes-literal-value\/","url_meta":{"origin":1829,"position":3},"title":"Error Resolved- Form action defaulting to &#8216;action&#8217; attribute&#8217;s literal value","author":"Jitendra","date":"March 30, 2011","format":false,"excerpt":"Error Resolved in Struts 2- Form action defaulting to 'action' attribute's literal value","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2034,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/tutorial-of-simple-jsp-tiles-application-without-struts\/","url_meta":{"origin":1829,"position":4},"title":"Tutorial of Simple JSP Tiles application without Struts","author":"Jitendra","date":"April 15, 2011","format":false,"excerpt":"Example of Simple JSP Tiles application without Struts","rel":"","context":"In &quot;JSP&quot;","block_context":{"text":"JSP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/jsp\/"},"img":{"alt_text":"Simple JSP Tiles without Struts","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/04\/Simple-JSP-Tiles-without-Struts.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1720,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/how-to-create-jsp-custom-tag-using-tag-interface-or-tagsupport\/","url_meta":{"origin":1829,"position":5},"title":"How to Create JSP Custom Tag \u2013 using Tag interface or TagSupport","author":"Jitendra","date":"March 17, 2011","format":false,"excerpt":"Tutorial of creating JSP Custom Tag \u2013 using Tag interface or TagSupport in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"How to Create Custom Tag in JSP","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/How-to-Create-Custom-Tag-in-JSP.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=1829"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1829\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=1829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=1829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=1829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}