<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<p>In this tutorial we will discuss about the <b>ValueStack </b>in the Struts2 how its work behind the scene. Fist lets see the high level picture of flow request data to Struts2 framework.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/11111-1.png" border="0" /></div>
<p><b>Step 1.</b> Client send the request to server.<br />
<b>Step 2. </b>Struts configuration file map to specific action class.<br />
<b>Step 3. </b>Action class has business service class to operate business logic and return result data to the action class and action class set this data to self member variables.<br />
<b>Step 4.</b> After setting result to member variable it send to the JSP to view.<br />
<b>Step 5.</b> JSP using the some TAGS to display result.<br />
<b>Step 6.</b> JSP prepare the response as HTML and return to client.</p>
<p><b>Now we will see the How Servlet work. High Level flow of request to Servlet.</b></p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/2222.png" border="0" /></div>
<p>Step-<br />
1. We are given objects to use, but we will need to do the &#8220;push&#8221; and &#8220;pull&#8221; of data ourseleves.<br />
2. Servlet places the business data into the session and the JSP accesses it.<br />
3 This has to be done for every servlet-to-JSP flow that data to be communicated.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/3333.png" border="0" /></div>
<p><b>Now we move to Struts2 framework how it is work internally. </b><br />
<b>Step 1. New Action objects are created for each request.</b></p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/444.png" border="0" /></div>
<p>In the above every requests have own Action instances with member variables. Now here there are some complicated to display member variable to JSP. it may be override to each other. So overcome this problem Struts 2 introduce to <b>ValueStack</b>.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/5555-1.png" border="0" /></div>
<h2><b>ValueStack- </b></h2>
<p>A valueStack is simply a stack that contains application specific objects such as action objects and other model object. At the execution time, action is placed on the top of the stack. We can put objects in the valuestack, query it and delete it.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/6666-1.png" border="0" /></div>
<p><b>1. It is not really a stack in the traditional sense.</b><br />
<b>2. It does stack up objects.</b><br />
<b>3. Behave like a virtual object.</b><br />
<b>4. Makes it easy to refer to member variables.</b></p>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; orphans: auto; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">The value stack is a set of several objects which keeps the following objects in the provided order:</div>
<table class="src" style="-webkit-text-stroke-width: 0px; background-color: #f7f7f7; border-collapse: collapse; border: 1px solid #d6d6d6; color: black; font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 8px 0px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; vertical-align: top; white-space: normal; widows: auto; width: 560px; word-spacing: 0px;">
<tbody style="margin: 0px; padding: 0px;">
<tr style="margin: 0px; padding: 0px;">
<th style="background-color: #eeeeee; border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px; text-align: left;">SN</th>
<th style="background-color: #eeeeee; border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px; text-align: left;">Objects &; Description</th>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">1</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">Temporary Objects</b><br />
There are various temporary objects which are created during execution of a page. For example the current iteration value for a collection being looped over in a JSP tag.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">2</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">The Model Object</b><br />
If you are using model objects in your struts application, the current model object is placed before the action on the value stack</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">3</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">The Action Object</b><br />
This will be the current action object which is being executed.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">4</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">Named Objects</b><br />
These objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes</td>
</tr>
</tbody>
</table>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; orphans: auto; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">The value stack can be accessed via the tags provided for JSP, Velocity or Freemarker. There are various tags which we will study in separate chapters, are used to get and set struts 2.0 value stack. You can get valueStack object inside your action as follows:</div>
<pre class="prettyprint prettyprinted" style="-webkit-text-stroke-width: 0px; background-color: #eeeeee; border: 1px solid #d6d6d6; color: black; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px 0px 10px; orphans: auto; padding: 5px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; width: 549.765625px; word-spacing: 0px;">ActionContext.getContext().getValueStack()</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; orphans: auto; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">Once you have a ValueStack object, you can use following methods to manipulate that object:</div>
<table class="src" style="-webkit-text-stroke-width: 0px; background-color: #f7f7f7; border-collapse: collapse; border: 1px solid #d6d6d6; color: black; font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 8px 0px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; vertical-align: top; white-space: normal; widows: auto; width: 560px; word-spacing: 0px;">
<tbody style="margin: 0px; padding: 0px;">
<tr style="margin: 0px; padding: 0px;">
<th style="background-color: #eeeeee; border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px; text-align: left;">SN</th>
<th style="background-color: #eeeeee; border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px; text-align: left;">ValueStack Methods &; Description</th>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">1</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">Object findValue(String expr)</b><br />
Find a value by evaluating the given expression against the stack in the default search order.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">2</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">CompoundRoot getRoot()</b><br />
Get the CompoundRoot which holds the objects pushed onto the stack.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">3</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">Object peek()</b><br />
Get the object on the top of the stack without changing the stack.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">4</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">Object pop()</b><br />
Get the object on the top of the stack and remove it from the stack.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">5</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">void push(Object o)</b><br />
Put this object onto the top of the stack.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">6</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">void set(String key, Object o)</b><br />
Sets an object on the stack with the given key so it is retrievable by findValue(key,&#8230;)</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">7</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">void setDefaultType(Class defaultType)</b><br />
Sets the default type to convert to if no type is provided when getting a value.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">8</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">void setValue(String expr, Object value)</b><br />
Attempts to set a property on a bean in the stack with the given expression using the default search order.</td>
</tr>
<tr style="margin: 0px; padding: 0px;">
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;">9</td>
<td style="border-collapse: collapse; border: 1px solid #d6d6d6; margin: 0px; padding: 5px;"><b style="margin: 0px; padding: 0px;">int size()</b><br />
Get the number of objects in the stack.</td>
</tr>
</tbody>
</table>
<h2 style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 1.6em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; text-align: start; text-indent: 0px; text-shadow: 1px 1px 2px #cccccc; text-transform: none; white-space: normal; word-spacing: 0px;">The OGNL:</h2>
<div style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><b style="margin: 0px; padding: 0px;">The Object-Graph Navigation Language</b> (OGNL) is a powerful expression language that is used to reference and manipulate data on the <b>ValueStack</b>. OGNL also helps in data transfer and type conversion.</div>
<div style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The OGNL is very similar to the JSP Expression Language. OGNL is based on the idea of having a root or default object within the context. The properties of the default or root object can be referenced using the markup notation, which is the pound symbol.</div>
<div style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">As mentioned earlier, <b>OGNL </b>is based on a context and Struts builds an <b>ActionContext </b>map for use with <b>OGNL</b>. The <b>ActionContext </b>map consists of the following:</div>
<ul class="list" style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; list-style: none outside none; margin: 0px; padding: 0px 0px 0px 15px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<li style="background-image: url('http://www.tutorialspoint.com/images/icon-bullet.png'); background-position: 0px 0px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 19px;">
<div style="margin: 0.8em 0px 1em; padding: 0px; text-align: justify;"><b style="margin: 0px; padding: 0px;">application</b> &#8211; application scoped variables</div>
</li>
<li style="background-image: url('http://www.tutorialspoint.com/images/icon-bullet.png'); background-position: 0px 0px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 19px;">
<div style="margin: 0.8em 0px 1em; padding: 0px; text-align: justify;"><b style="margin: 0px; padding: 0px;">session</b> &#8211; session scoped variables</div>
</li>
<li style="background-image: url('http://www.tutorialspoint.com/images/icon-bullet.png'); background-position: 0px 0px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 19px;">
<div style="margin: 0.8em 0px 1em; padding: 0px; text-align: justify;"><b style="margin: 0px; padding: 0px;">root / value stack</b> &#8211; all your action variables are stored here</div>
</li>
<li style="background-image: url('http://www.tutorialspoint.com/images/icon-bullet.png'); background-position: 0px 0px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 19px;">
<div style="margin: 0.8em 0px 1em; padding: 0px; text-align: justify;"><b style="margin: 0px; padding: 0px;">request</b> &#8211; request scoped variables</div>
</li>
<li style="background-image: url('http://www.tutorialspoint.com/images/icon-bullet.png'); background-position: 0px 0px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 19px;">
<div style="margin: 0.8em 0px 1em; padding: 0px; text-align: justify;"><b style="margin: 0px; padding: 0px;">parameters</b> &#8211; request parameters</div>
</li>
<li style="background-image: url('http://www.tutorialspoint.com/images/icon-bullet.png'); background-position: 0px 0px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 19px;">
<div style="margin: 0.8em 0px 1em; padding: 0px; text-align: justify;"><b style="margin: 0px; padding: 0px;">atributes</b> &#8211; the attributes stored in page, request, session and application scope</div>
</li>
</ul>
<div id="ads-id" align="center"></div>
<div style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">It is important to understand that the Action object is always available in the value stack. So, therefore if your Action object has properties x and y there are readily available for you to use.</div>
<div style="background-color: white; font-family: Helvetica,Arial,sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0.8em 0px 1em; padding: 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Objects in the <b>ActionContext </b>are referred using the pound symbol, however, the objects in the value stack can be directly referenced, for example if <b style="margin: 0px; padding: 0px;">employee</b> is a property of an action class then it can get referenced as follows:</div>
</div>
<pre class="highlight"><;s:property value="name"/>; 
</pre>
</div>
<p>instead of</p>
<pre class="highlight"><;s:property value="#name"/>; 
</pre>
<p>If you have an attribute in session called &#8220;login&#8221; you can retrieve it as follows:</p>
<pre class="highlight"><;s:property value="#session.login"/>; 
</pre>
<p>OGNL also supports dealing with collections &#8211; namely Map, List and Set. For example to display a dropdown list of colors, you could do:</p>
<pre class="highlight"><;s:property name="color" list="{'red','yellow','green'}"/>; 
</pre>
<h2><b>ValueStack/OGNL Example:-</b></h2>
<h3>CREATE ACTION:</h3>
<p>Let us consider following action class where we are accessing valueStack and then setting few keys which we will access using OGNL in our view ie. JSP page.</p>
</div>
<pre class="highlight">package com.dineshonjava.struts2.action; 
 
import java.util.HashMap; 
import java.util.Map; 
 
import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.ActionSupport; 
import com.opensymphony.xwork2.util.ValueStack; 
 
/** 
 * @author Dinesh Rajput 
 * 
 */ 
public class HelloWorldAction extends ActionSupport { 
 private static final long serialVersionUID = 4956157388836635122L; 
 private String name; 
 
 public String execute() throws Exception { 
 ValueStack stack = ActionContext.getContext().getValueStack(); 
 Map<;String, Object>; context = new HashMap<;String, Object>;(); 
 
 context.put("key1", new String("This is key1")); 
 context.put("key2", new String("This is key2")); 
 stack.push(context); 
 
 System.out.println("Size of the valueStack: " + stack.size()); 
 return "success"; 
 } 
 
 public String getName() { 
 return name; 
 } 
 
 public void setName(String name) { 
 this.name = name; 
 } 
} 
 
</pre>
<p>Actually, Struts 2 adds your action to the top of the <b>valueStack </b>when executed. So, the usual way to put stuff on the Value Stack is to add getters/setters for the values to your Action class and then use <b><;s:property>;</b> tag to access the values. But I&#8217;m showing you how exactly <b>ActionContext </b>and <b>ValueStack </b>work in struts.</p>
<h3><b>CREATE VIEWS</b></h3>
<p>Let us create the below jsp files <b>success.jsp in</b> the <b>WebRoot </b>folder in your eclipse project. This view will be displayed in case action returns success:</p>
</div>
<pre class="highlight"><;%@ page contentType="text/html; charset=UTF-8" %>; 
<;%@ taglib prefix="s" uri="/struts-tags" %>; 
<;html>; 
<;head>; 
<;title>;Hello World<;/title>; 
<;/head>; 
<;body>; 
 Entered value : <;s:property value="name"/>;<;br/>; 
 Value of key 1 : <;s:property value="key1" />;<;br/>; 
 Value of key 2 : <;s:property value="key2" />; <;br/>; 
<;/body>; 
<;/html>; 
</pre>
</div>
<p>We also need to create<i><b> index.jsp</b></i> in the <i><b>WebRoot </b></i>folder whose content is as follows:</p>
<pre class="highlight"><;%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
 pageEncoding="ISO-8859-1"%>; 
<;%@ taglib prefix="s" uri="/struts-tags"%>; 
 <;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">; 
<;html>; 
<;head>; 
<;title>;Hello World<;/title>; 
<;/head>; 
<;body>; 
 <;h1>;Hello World From Struts2<;/h1>; 
 <;form action="hello">; 
 <;label for="name">;Please enter your name<;/label>;<;br/>; 
 <;input type="text" name="name"/>; 
 <;input type="submit" value="Say Hello"/>; 
 <;/form>; 
<;/body>; 
<;/html>; 
</pre>
</div>
<h3><b>CONFIGURATION FILES</b></h3>
<p><b>Following is the content of <i>struts.xml</i> file:</b></p>
<pre class="highlight"><;?xml version="1.0" encoding="UTF-8" ?>; 
<;!DOCTYPE struts PUBLIC 
 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
 "http://struts.apache.org/dtds/struts-2.0.dtd">; 
 
<;struts>; 
 <;constant name="struts.devMode" value="true" />; 
 <;package name="helloworld" extends="struts-default">; 
 <;action name="hello" class="com.dineshonjava.struts2.action.HelloWorldAction" method="execute">; 
 <;result name="success">;/success.jsp<;/result>; 
 <;/action>; 
 <;/package>; 
 <;/struts>; 
</pre>
</div>
<p><b>Following is the content of <i>web.xml</i> file:</b></p>
<pre class="highlight"><;?xml version="1.0" encoding="UTF-8"?>; 
<;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">; 
 <;display-name>;Struts2ValueStack<;/display-name>; 
 <;filter>; 
 <;filter-name>;struts2<;/filter-name>; 
 <;filter-class>; 
 org.apache.struts2.dispatcher.FilterDispatcher 
 <;/filter-class>; 
 <;/filter>; 
 <;filter-mapping>; 
 <;filter-name>;struts2<;/filter-name>; 
 <;url-pattern>;/*<;/url-pattern>; 
 <;/filter-mapping>; 
 <;welcome-file-list>; 
 <;welcome-file>;index.jsp<;/welcome-file>; 
 <;/welcome-file-list>; 
<;/web-app>; 
</pre>
<p>Right click on the project name and click<b> Export >; WAR</b> File to create a War file. Then deploy this WAR in the Tomcat&#8217;s webapps directory. Finally, start Tomcat server and try to access<br />
URL <i><b>http://localhost:8080/doj/</b></i>. This will give you following screen:</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/777-1.png" border="0" /></div>
<p>Now enter any word in the given text box and click &#8220;<b>Say Hello</b>&#8221; button to execute the defined action. Now if you will check the log generated, you will find following text at the bottom:</p>
<div style="background-color: #ff99cc;"><b>output on console:</b><br />
Size of the valueStack: 3</div>
<p>and this will display following screen, which will display whatever value you will enter and value of key1 and key2 which we had put on <b>ValueStack</b>.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/07/8888-2.png" border="0" /></div>
<p> ;</p>
</div>
<h3><b>Download SourceCode + Libs</b><br />
<a href="https://sites.google.com/a/dineshonjava.com/dineshonjava/dineshonjava/Struts2ValueStack.zip?attredirects=0&;d=1" target="_blank" rel="noopener">Struts2ValueStack.zip</a></h3>
<p> ;</p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/a-tag-and-business-service/">Previous</a> <;<; || <a href="https://dineshonjava.com/struts-2-baby-step-to-learn/">Index </a>|| >;>;<a href="https://dineshonjava.com/struts-2-ognl/">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/a-tag-and-business-service/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/struts-2-ognl/">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: '390'});
});
</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…