<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<p>The <b>Object Graph Navigation Language</b> (OGNL) is an expression language. It simplifies the accessibility of data stored in the <b>ActionContext</b>.</p>
<p>The struts framework sets the <b>ValueStack</b> as the root object of OGNL. Notice that action object is pushed into the <b>ValueStack</b>. We can direct access the action property.</p>
<div class="codeblock">
<pre class="highlight"><;s:property value="username"/>; 
</pre>
</div>
<p>Here, username is the property key<br />
.<br />
The struts framework places other objects in <b>ActionContext </b>also e.g. map representing the <b>request</b>, <b>session</b>, <b>application</b> scopes.</p>
<p>To get these values i.e. not the action property, we need to use <b># </b> notation. For example to get the data from session scope, we need to use<b> #session</b> as given in the following example:</p>
<div id="ads-id" align="center"></div>
<div class="codeblock">
<pre class="highlight"><;s:property name="#session.username"/>; 
</pre>
</div>
<p>(or)</p>
<div class="codeblock">
<pre class="highlight"><;s:property name="#session['username']"/>; 
</pre>
</div>
</div>
<h2><b id="h1"><br />
Struts 2 <i>ActionInvocation</i></b></h2>
<p>The <b>ActionInvocation</b> represents the execution state of an action. It holds the action and interceptors objects.</p>
<p>The struts framework provides <b>ActionInvocation interface</b> to deal with <b>ActionInvocation</b>. It provides many methods, some of them can be used to get the instance of <b>ValueStack</b>, <b>ActionProxy</b>, <b>ActionContext</b>, Result etc.</p>
<h2 id="h3tag">Methods of <i>ActionInvocation </i>Interface</h2>
<p>The commonly used methods of ActionInvocation interface are as follows:<br />
1)<b>public ActionContext getInvocationContext()</b> returns the ActionContext object associated with the ActionInvocation.<br />
2)<b>public ActionProxy getProxy()</b> returns the ActionProxy instance holding this ActionInvocation.<br />
3)<b>public ValueStack getStack()</b> returns the instance of ValueStack.<br />
4)<b>public Action getAction()</b> returns the instance of Action associated with this ActionInvocation.<br />
5)<b>public void invoke()</b> invokes the next resource in processing this ActionInvocation.<br />
6)<b>public Result getResult()</b> returns the instance of Result.</p>
<h2><b id="h1"><br />
Struts 2 <i>ActionContex</i>&#8211; </b></h2>
<p>The <b>ActionContext </b>is a container of objects in which action is executed. The values stored in the <b>ActionContext </b>are unique per thread (i.e. <b>ThreadLocal</b>). So we don&#8217;t need to make our action thread safe.</p>
<p>We can get the reference of <b>ActionContext</b> by calling the <b>getContext() </b>method of <b>ActionContext </b>class. It is a static factory method. <b>For example:</b></p>
<div class="codeblock">
<pre class="highlight">ActionContext context = ActionContext.getContext(); 
</pre>
</div>
</div>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/the-valuestack-in-struts-2/">Previous</a> <;<; || <a href="https://dineshonjava.com/struts-2-baby-step-to-learn/">Index </a>|| >;>;<a href="https://dineshonjava.com/struts-2-actions/">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/the-valuestack-in-struts-2/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/struts-2-actions/">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: '389'});
});
</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…