{"id":50623,"date":"2017-09-26T11:00:36","date_gmt":"2017-09-26T08:00:36","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=50623"},"modified":"2017-09-25T17:04:32","modified_gmt":"2017-09-25T14:04:32","slug":"struts-jsp-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/","title":{"rendered":"Struts JSP Example"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\">Apache Struts2<\/span> is an elegant, extensible framework for creating the enterprise-ready Java web applications. The framework is designed to streamline the development cycle i.e. from building to deploying and to maintaining the applications over time. In this example, we will show developers how to create a simple Hello World example in Struts2.<\/p>\n<h2>1. Introduction<\/h2>\n<h3>1.1 Struts Framework<\/h3>\n<ul>\n<li>Struts framework is based on a set of Java technologies like Servlet, <code>JSP<\/code>, <code>JSTL<\/code>, <code>XML<\/code>, Velocity etc which provides the MVC (i.e. Model View Controller) implementation and a ready to use Validation framework<\/li>\n<li>The power of Struts lies in its model layer by which it can be integrated with other Java technologies, for e.g.: <code>JDBC<\/code>, <code>EJB<\/code>, Spring, Hibernate etc<\/li>\n<li>Struts framework is a complete web framework as it provides the <span style=\"text-decoration: underline;\">Web Form Components<\/span>, <span style=\"text-decoration: underline;\">Validators<\/span>, <span style=\"text-decoration: underline;\">Error Handling<\/span>, <span style=\"text-decoration: underline;\">Internationalization<\/span>, <span style=\"text-decoration: underline;\">Tiles<\/span> and its own <span style=\"text-decoration: underline;\">Controller component<\/span><\/li>\n<li>Struts2 framework also supports the annotation based configurations which are easy to use and are more intuitive<\/li>\n<li>Struts2 also comes with powerful APIs to configure the Interceptors that greatly reduce the coupling in an application<\/li>\n<\/ul>\n<h4>1.1.1 How Struts Work?<\/h4>\n<p>When developers use Struts, the framework provides them with a <em>Controller Servlet<\/em> i.e. <code>ActionServlet<\/code> which is defined in the Struts libraries that are included in an application. This controller servlet is automatically registered in the deployment descriptor file (<code>web.xml<\/code>) as shown in the below figure.<\/p>\n<p><figure id=\"attachment_50624\" aria-describedby=\"caption-attachment-50624\" style=\"width: 598px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-architecture-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50624\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-architecture-guide-1.jpg\" alt=\"Fig. 1: Struts2 Request Response Overview\" width=\"598\" height=\"397\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-architecture-guide-1.jpg 598w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-architecture-guide-1-300x199.jpg 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/a><figcaption id=\"caption-attachment-50624\" class=\"wp-caption-text\">Fig. 1: Struts2 Request Response Overview<\/figcaption><\/figure><\/p>\n<p>The controller servlet uses a <code>struts-config.xml<\/code> file to map the incoming requests to the Struts Action objects and instantiate any <code>ActionForm<\/code> object associated with the action to temporarily store the form data. The Action Object processes requests by using it\u2019s <code>execute()<\/code> method, while making the use of any stored data. Once the Action Object processes a request, it stores any new data in the same or in a different result bean and forwards the response to an appropriate view.<\/p>\n<h4>1.1.2 Struts2 Advantages<\/h4>\n<ul>\n<li>The Action classes code is not tightly coupled to the Struts framework or the Servlet API<\/li>\n<li><code>ActionForm<\/code> is a simple <code>POJO<\/code> class which do not need to implement any interface or extend from any class<\/li>\n<li>Unit testing of the Struts2 Action Class is easy because it doesn\u2019t need the complex <code>HttpServletRequest<\/code> and <code>HttpServletResponse<\/code> objects<\/li>\n<li>The use of annotations results in the reduction of code complexity<\/li>\n<li>Struts2 tags provide the style sheet driven form tags which reduce the coding efforts and coding of the form validation<\/li>\n<\/ul>\n<p>Now, open up the Eclipse IDE and let\u2019s see how to implement a simple hello world application in the struts2 framework!<\/p>\n<h2>2. Struts JSP Example<\/h2>\n<h3>2.1 Tools Used<\/h3>\n<p>We are using Eclipse Kepler SR2, JDK 8 and Maven. Having said that, we have tested the code against JDK 1.7 and it works well.<\/p>\n<h3>2.2 Project Structure<\/h3>\n<p>Firstly, let\u2019s review the final project structure, in case you are confused about where you should create the corresponding files or folder later!<\/p>\n<p><figure id=\"attachment_50625\" aria-describedby=\"caption-attachment-50625\" style=\"width: 323px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-structure-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50625\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-structure-guide-1.jpg\" alt=\"Fig. 2: Struts2 Application Structure\" width=\"323\" height=\"450\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-structure-guide-1.jpg 323w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-structure-guide-1-215x300.jpg 215w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><\/a><figcaption id=\"caption-attachment-50625\" class=\"wp-caption-text\">Fig. 2: Struts2 Application Structure<\/figcaption><\/figure><\/p>\n<h3>2.3 Project Creation<\/h3>\n<p>This section will demonstrate on how to create a Java-based Maven project with Eclipse. In Eclipse IDE, go to <code>File -&gt; New -&gt; Maven Project<\/code>.<\/p>\n<p><figure id=\"attachment_50626\" aria-describedby=\"caption-attachment-50626\" style=\"width: 652px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50626\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-1.jpg\" alt=\"Fig. 3: Create Maven Project\" width=\"652\" height=\"605\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-1.jpg 652w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-1-300x278.jpg 300w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/a><figcaption id=\"caption-attachment-50626\" class=\"wp-caption-text\">Fig. 3: Create Maven Project<\/figcaption><\/figure><\/p>\n<p>In the New Maven Project window, it will ask you to select project location. By default, &#8216;Use default workspace location&#8217; will be selected. Just click on next button to proceed.<\/p>\n<p><figure id=\"attachment_50627\" aria-describedby=\"caption-attachment-50627\" style=\"width: 599px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50627\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-2.jpg\" alt=\"Fig. 4: Project Details\" width=\"599\" height=\"545\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-2.jpg 599w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-2-300x273.jpg 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/a><figcaption id=\"caption-attachment-50627\" class=\"wp-caption-text\">Fig. 4: Project Details<\/figcaption><\/figure><\/p>\n<p>Select the &#8216;Maven Web App&#8217; Archetype from the list of options and click next.<\/p>\n<p><figure id=\"attachment_50628\" aria-describedby=\"caption-attachment-50628\" style=\"width: 598px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50628\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-3.jpg\" alt=\"Fig. 5: Archetype Selection\" width=\"598\" height=\"541\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-3.jpg 598w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-3-300x271.jpg 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/a><figcaption id=\"caption-attachment-50628\" class=\"wp-caption-text\">Fig. 5: Archetype Selection<\/figcaption><\/figure><\/p>\n<p>It will ask you to &#8216;Enter the group and the artifact id for the project&#8217;. We will input the details as shown in the below image. The version number will be by default: <code>0.0.1-SNAPSHOT<\/code>.<\/p>\n<p><figure id=\"attachment_50629\" aria-describedby=\"caption-attachment-50629\" style=\"width: 598px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50629\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-4.jpg\" alt=\"Fig. 6: Archetype Parameters\" width=\"598\" height=\"543\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-4.jpg 598w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-4-300x272.jpg 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/a><figcaption id=\"caption-attachment-50629\" class=\"wp-caption-text\">Fig. 6: Archetype Parameters<\/figcaption><\/figure><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Click on Finish and the creation of a maven project is completed. If you observe, it has downloaded the maven dependencies and a <code>pom.xml<\/code> file will be created. It will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\t&lt;groupId&gt;Struts2Jsp&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;Struts2Jsp&lt;\/artifactId&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;packaging&gt;war&lt;\/packaging&gt;\r\n&lt;\/project&gt;\r\n<\/pre>\n<p>We can start adding the dependencies that developers want like Struts2 Core etc. Let\u2019s start building the application!<\/p>\n<h2>3. Application Building<\/h2>\n<p>Below are the steps involved in developing this application.<\/p>\n<h3>3.1 Maven Dependencies<\/h3>\n<p>Here, we specify the dependency for the Struts2 framework. The rest dependencies will be automatically resolved by Maven, such as Struts2 Core, OGNL etc. The <strong>updated<\/strong> file will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n\txsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\t&lt;groupId&gt;Struts2Jsp&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;Struts2Jsp&lt;\/artifactId&gt;\r\n\t&lt;packaging&gt;war&lt;\/packaging&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;dependencies&gt;\r\n\t\t&lt;!-- Servlet API Dependency --&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;javax.servlet-api&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;3.1.0&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;!-- Struts2 Core Framework Dependency --&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.apache.struts&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;struts2-core&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;2.3.24.1&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t&lt;\/dependencies&gt;\r\n\t&lt;build&gt;\r\n\t\t&lt;finalName&gt;${project.artifactId}&lt;\/finalName&gt;\r\n\t&lt;\/build&gt;\r\n&lt;\/project&gt;<\/pre>\n<h3>3.2 Java Class Creation<\/h3>\n<p>Let\u2019s create the required Java files. Right-click on <code>src\/main\/java<\/code> folder, <code>New -&gt; Package<\/code>.<\/p>\n<p><figure id=\"attachment_50633\" aria-describedby=\"caption-attachment-50633\" style=\"width: 682px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50633\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-5.jpg\" alt=\"Fig. 7: Java Package Creation\" width=\"682\" height=\"658\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-5.jpg 682w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-5-300x289.jpg 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><figcaption id=\"caption-attachment-50633\" class=\"wp-caption-text\">Fig. 7: Java Package Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open where we will enter the package name as: <code>com.jcg.struts2.jsp<\/code>.<\/p>\n<p><figure id=\"attachment_50634\" aria-describedby=\"caption-attachment-50634\" style=\"width: 516px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50634\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-6.jpg\" alt=\"Fig. 8: Java Package Name (com.jcg.struts2.jsp)\" width=\"516\" height=\"425\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-6.jpg 516w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-6-300x247.jpg 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/a><figcaption id=\"caption-attachment-50634\" class=\"wp-caption-text\">Fig. 8: Java Package Name (com.jcg.struts2.jsp)<\/figcaption><\/figure><\/p>\n<p>Once the package is created in the application, we will need to create the Struts2 action class. Right-click on the newly created package: <code>New -&gt; Class<\/code>.<\/p>\n<p><figure id=\"attachment_50635\" aria-describedby=\"caption-attachment-50635\" style=\"width: 690px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-7.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50635\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-7.jpg\" alt=\"Fig. 9: Java Class Creation\" width=\"690\" height=\"696\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-7.jpg 690w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-7-150x150.jpg 150w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-7-297x300.jpg 297w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-7-70x70.jpg 70w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/a><figcaption id=\"caption-attachment-50635\" class=\"wp-caption-text\">Fig. 9: Java Class Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open and enter the file name as: <code>LinkAction<\/code>. The action class will be created inside the package: <code>com.jcg.struts2.jsp<\/code>.<\/p>\n<p><figure id=\"attachment_50636\" aria-describedby=\"caption-attachment-50636\" style=\"width: 536px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-8.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50636\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-8.jpg\" alt=\"Fig. 10: Java Class (LinkAction.java)\" width=\"536\" height=\"629\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-8.jpg 536w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-guide-8-256x300.jpg 256w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><figcaption id=\"caption-attachment-50636\" class=\"wp-caption-text\">Fig. 10: Java Class (LinkAction.java)<\/figcaption><\/figure><\/p>\n<h4>3.2.1 Implementation of Action Class<\/h4>\n<p><span style=\"text-decoration: underline;\">Actions are the core of the Struts2 framework<\/span>, as they are for any Model View Controller framework. But the action servers in two important capacities i.e.<\/p>\n<ul>\n<li>First, the action class is not required to implement any interface or extend any class<\/li>\n<li>Second, the action class is required to create an <code>execute()<\/code> method to put all the business logic inside and return a string value to tell the application where to redirect<\/li>\n<\/ul>\n<p>Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>LinkAction.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jcg.struts2.jsp;\r\n\r\npublic class LinkAction {\r\n\r\n\tprivate String user_name;\r\n\r\n\tpublic String getUser_name() {\r\n\t\treturn user_name;\r\n\t}\r\n\r\n\tpublic void setUser_name(String user_name) {\r\n\t\tthis.user_name = user_name;\r\n\t}\r\n\r\n\t\/\/ All Struts Logic Goes In This Method\r\n\tpublic String execute() {\r\n\t\treturn \"success\";\r\n\t}\r\n}<\/pre>\n<h3>3.3 Configuration Files<\/h3>\n<p>Let\u2019s write all the configuration files involved in this application.<\/p>\n<h4>3.3.1 Struts Configuration File<\/h4>\n<p>To configure the struts2 framework, developers need to implement a configuration file i.e. <code>struts.xml<\/code>. In this file, we will define the result tag which maps a particular action with a <code>JSP<\/code> page. Right-click on the <code>src\/main\/resources<\/code> folder, <code>New -&gt; Other<\/code>.<\/p>\n<p><figure id=\"attachment_50637\" aria-describedby=\"caption-attachment-50637\" style=\"width: 670px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50637\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-1.jpg\" alt=\"Fig. 11: XML File Creation\" width=\"670\" height=\"656\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-1.jpg 670w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-1-300x294.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-1-70x70.jpg 70w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/a><figcaption id=\"caption-attachment-50637\" class=\"wp-caption-text\">Fig. 11: XML File Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open and select the wizard as a <code>XML<\/code> file.<\/p>\n<p><figure id=\"attachment_50638\" aria-describedby=\"caption-attachment-50638\" style=\"width: 517px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50638\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-2.jpg\" alt=\"Fig. 12: Wizard Selection\" width=\"517\" height=\"598\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-2.jpg 517w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-2-259x300.jpg 259w\" sizes=\"(max-width: 517px) 100vw, 517px\" \/><\/a><figcaption id=\"caption-attachment-50638\" class=\"wp-caption-text\">Fig. 12: Wizard Selection<\/figcaption><\/figure><\/p>\n<p>Again, a pop-up window will open. Verify the parent folder location as: <code>Struts2Jsp\/src\/main\/resources<\/code> and enter the file name as: <code>struts.xml<\/code>. Click Finish.<\/p>\n<p><figure id=\"attachment_50639\" aria-describedby=\"caption-attachment-50639\" style=\"width: 518px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50639\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-3.jpg\" alt=\"Fig. 13: struts.xml\" width=\"518\" height=\"595\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-3.jpg 518w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-xml-guide-3-261x300.jpg 261w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/a><figcaption id=\"caption-attachment-50639\" class=\"wp-caption-text\">Fig. 13: struts.xml<\/figcaption><\/figure><\/p>\n<p>Once the <code>XML<\/code> file is created, we will add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>struts.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;!DOCTYPE struts PUBLIC \"-\/\/Apache Software Foundation\/\/DTD Struts Configuration 2.0\/\/EN\" \"http:\/\/struts.apache.org\/dtds\/struts-2.0.dtd\"&gt;\r\n&lt;struts&gt;\r\n\t&lt;package name=\"default\" extends=\"struts-default\"&gt;\r\n\t\t&lt;action name=\"Login\"&gt;\r\n\t\t\t&lt;result&gt;views\/login.jsp&lt;\/result&gt;\r\n\t\t&lt;\/action&gt;\r\n\t\t&lt;action name=\"Welcome\" class=\"com.jcg.struts2.jsp.LinkAction\"&gt;\r\n\t\t\t&lt;result name=\"success\"&gt;views\/welcomeUser.jsp&lt;\/result&gt;\r\n\t\t&lt;\/action&gt;\r\n\t&lt;\/package&gt;\r\n&lt;\/struts&gt;<\/pre>\n<h4>3.3.2 Web Deployment Descriptor<\/h4>\n<p>The <code>web.xml<\/code> file declares a filter (i.e. <code>StrutsPrepareAndExecuteFilter<\/code>) to configure the struts2 framework in the application. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>web.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;!DOCTYPE web-app PUBLIC \"-\/\/Sun Microsystems, Inc.\/\/DTD Web Application 2.3\/\/EN\" \"http:\/\/java.sun.com\/dtd\/web-app_2_3.dtd\"&gt;\r\n&lt;web-app&gt;\r\n   &lt;display-name&gt;Struts 2 Web Application&lt;\/display-name&gt;\r\n   &lt;filter&gt;\r\n      &lt;filter-name&gt;struts2&lt;\/filter-name&gt;\r\n      &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;\/filter-class&gt;\r\n   &lt;\/filter&gt;\r\n   &lt;filter-mapping&gt;\r\n      &lt;filter-name&gt;struts2&lt;\/filter-name&gt;\r\n      &lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;\r\n   &lt;\/filter-mapping&gt;\r\n&lt;\/web-app&gt;\r\n<\/pre>\n<h3>3.4 Creating JSP View<\/h3>\n<p>Let us write a simple <code>JSP<\/code> to illustrate this tutorial. Right-click on <code>Struts2Jsp\/src\/main\/webapp\/views<\/code> folder, <code>New -&gt; JSP File<\/code>.<\/p>\n<p><figure id=\"attachment_50640\" aria-describedby=\"caption-attachment-50640\" style=\"width: 662px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50640\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-1.jpg\" alt=\"Fig. 14: JSP Creation\" width=\"662\" height=\"658\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-1.jpg 662w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-1-150x150.jpg 150w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-1-300x298.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-1-70x70.jpg 70w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/a><figcaption id=\"caption-attachment-50640\" class=\"wp-caption-text\">Fig. 14: JSP Creation<\/figcaption><\/figure><\/p>\n<p>Verify the parent folder location as: <code>Struts2Jsp\/src\/main\/webapp\/views<\/code> and enter the filename as: <code>login.jsp<\/code>. Click Finish.<\/p>\n<p><figure id=\"attachment_50641\" aria-describedby=\"caption-attachment-50641\" style=\"width: 519px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50641\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-2.jpg\" alt=\"Fig. 15: login.jsp\" width=\"519\" height=\"597\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-2.jpg 519w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-2-261x300.jpg 261w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/a><figcaption id=\"caption-attachment-50641\" class=\"wp-caption-text\">Fig. 15: login.jsp<\/figcaption><\/figure><\/p>\n<p>Repeat the step (i.e. Fig. 14) and enter the filename as: <code>welcomeUser.jsp<\/code>. Click Finish.<\/p>\n<p><figure id=\"attachment_50642\" aria-describedby=\"caption-attachment-50642\" style=\"width: 518px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50642\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-3.jpg\" alt=\"Fig. 16: welcomeUser.jsp\" width=\"518\" height=\"594\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-3.jpg 518w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts-jsp-example-project-jsp-guide-3-262x300.jpg 262w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/a><figcaption id=\"caption-attachment-50642\" class=\"wp-caption-text\">Fig. 16: welcomeUser.jsp<\/figcaption><\/figure><\/p>\n<h4>3.4.1 Application\u2019s Login Page<\/h4>\n<p>A login page uses the struts2 tags for displaying the username and password input fields along with a submit button. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>login.jsp<\/em><\/span><\/p>\n<pre class=\"brush:html; wrap-lines:false;\">&lt;%@ page contentType=\"text\/html; charset=UTF-8\"%&gt;\r\n&lt;%@ taglib prefix=\"s\" uri=\"\/struts-tags\"%&gt;\r\n&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"&gt;\r\n&lt;html&gt;\r\n   &lt;head&gt;\r\n      &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\r\n      &lt;title&gt;Struts2 JSP Example&lt;\/title&gt;\r\n   &lt;\/head&gt;\r\n   &lt;body&gt;\r\n      &lt;h1&gt;Struts2 Hello World Example&lt;\/h1&gt;\r\n      &lt;s:form action=\"Welcome\"&gt;\r\n         &lt;s:textfield name=\"user_name\" label=\"Username\" \/&gt;\r\n         &lt;s:password name=\"password\" label=\"Password\" \/&gt;\r\n         &lt;s:submit \/&gt;\r\n      &lt;\/s:form&gt;\r\n   &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h4>3.4.2 Application\u2019s Welcome Page<\/h4>\n<p>A view page to display the welcome message to the user. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>welcomeUser.jsp<\/em><\/span><\/p>\n<pre class=\"brush:html; wrap-lines:false;\">&lt;%@ page contentType=\"text\/html; charset=UTF-8\"%&gt;\r\n&lt;%@ taglib prefix=\"s\" uri=\"\/struts-tags\"%&gt;\r\n&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"&gt;\r\n&lt;html&gt;\r\n   &lt;head&gt;\r\n      &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\r\n      &lt;title&gt;Struts2 JSP Example&lt;\/title&gt;\r\n   &lt;\/head&gt;\r\n   &lt;body&gt;\r\n      &lt;h1&gt;Struts2 Hello World Example&lt;\/h1&gt;\r\n      &lt;h4&gt;\r\n         Hello &lt;s:property value=\"user_name\"\/&gt;\r\n      &lt;\/h4&gt;\r\n   &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2>4. Run the Application<\/h2>\n<p>As we are ready with all the changes, let us compile the project and deploy the application on the Tomcat7 server. To deploy the application on Tomat7, right-click on the project and navigate to <code>Run as -&gt; Run on Server<\/code>.<\/p>\n<p><figure id=\"attachment_50643\" aria-describedby=\"caption-attachment-50643\" style=\"width: 759px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-deploy-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50643\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-deploy-guide-1.jpg\" alt=\"Fig. 17: How to Deploy Application on Tomcat\" width=\"759\" height=\"680\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-deploy-guide-1.jpg 759w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-deploy-guide-1-300x269.jpg 300w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/a><figcaption id=\"caption-attachment-50643\" class=\"wp-caption-text\">Fig. 17: How to Deploy Application on Tomcat<\/figcaption><\/figure><\/p>\n<p>Tomcat will deploy the application in its web-apps folder and shall start its execution to deploy the project so that we can go ahead and test it on the browser.<\/p>\n<h2>5. Project Demo<\/h2>\n<p>Open your favorite browser and hit the following URL. The output page will be displayed.<\/p>\n<p><code>http:\/\/localhost:8085\/Struts2Jsp\/Login.action<\/code><\/p>\n<p>Server name (localhost) and port (8085) may vary as per your Tomcat configuration. Developers can debug the example and see what happens after every step. Enjoy!<\/p>\n<p><figure id=\"attachment_50644\" aria-describedby=\"caption-attachment-50644\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50644\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-1.jpg\" alt=\"Fig. 18: Login Page \" width=\"849\" height=\"159\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-1.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-1-300x56.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-1-768x144.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-50644\" class=\"wp-caption-text\">Fig. 18: Login Page<\/figcaption><\/figure><\/p>\n<p>Now, enter any random username\/password and click on <code>Submit<\/code> button. Developers should see the following result if everything is fine with the application.<\/p>\n<p><figure id=\"attachment_50645\" aria-describedby=\"caption-attachment-50645\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50645\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-2.jpg\" alt=\"Fig. 19: Welcome User Page\" width=\"849\" height=\"129\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-2.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-2-300x46.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/struts2-jsp-example-project-demo-guide-2-768x117.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-50645\" class=\"wp-caption-text\">Fig. 19: Welcome User Page<\/figcaption><\/figure><\/p>\n<p>That\u2019s all for this post. Happy Learning!<\/p>\n<h2>6. Conclusion<\/h2>\n<p>In this tutorial, developers learned how to download, create a new project in Eclipse IDE, and add Struts2 libraries to write a simple struts2 example. That\u2019s all for this tutorial and I hope this article served you whatever you were looking for.<\/p>\n<h2>7. Download the Eclipse Project<\/h2>\n<p>This was an example of the struts2 framework for the beginners.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/09\/Struts2Jsp.zip\" target=\"_blank\" rel=\"noopener\"><strong>Struts2Jsp<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Apache Struts2 is an elegant, extensible framework for creating the enterprise-ready Java web applications. The framework is designed to streamline the development cycle i.e. from building to deploying and to maintaining the applications over time. In this example, we will show developers how to create a simple Hello World example in Struts2. 1. Introduction 1.1 &hellip;<\/p>\n","protected":false},"author":119,"featured_media":18727,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[843],"tags":[1030,831],"class_list":["post-50623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-struts-2","tag-jsp","tag-struts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Struts JSP Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this tutorial, we will show developers how to create a simple Hello World example in the Struts2 framework.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Struts JSP Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we will show developers how to create a simple Hello World example in the Struts2 framework.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-26T08:00:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"Struts JSP Example\",\"datePublished\":\"2017-09-26T08:00:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\"},\"wordCount\":1454,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg\",\"keywords\":[\"jsp\",\"struts\"],\"articleSection\":[\"Struts 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\",\"name\":\"Struts JSP Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg\",\"datePublished\":\"2017-09-26T08:00:36+00:00\",\"description\":\"In this tutorial, we will show developers how to create a simple Hello World example in the Struts2 framework.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Struts 2\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/struts-2\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Struts JSP Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Struts JSP Example - Java Code Geeks","description":"In this tutorial, we will show developers how to create a simple Hello World example in the Struts2 framework.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/","og_locale":"en_US","og_type":"article","og_title":"Struts JSP Example - Java Code Geeks","og_description":"In this tutorial, we will show developers how to create a simple Hello World example in the Struts2 framework.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-09-26T08:00:36+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"Struts JSP Example","datePublished":"2017-09-26T08:00:36+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/"},"wordCount":1454,"commentCount":2,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg","keywords":["jsp","struts"],"articleSection":["Struts 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/","name":"Struts JSP Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg","datePublished":"2017-09-26T08:00:36+00:00","description":"In this tutorial, we will show developers how to create a simple Hello World example in the Struts2 framework.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/01\/apache-struts-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/struts-2\/struts-jsp-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"Struts 2","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/struts-2\/"},{"@type":"ListItem","position":5,"name":"Struts JSP Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/50623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=50623"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/50623\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/18727"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=50623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=50623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=50623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}