title: Accessing action instance variables and model-driven bean variable values in JSP
body: <p>I have <code>searchKey</code> as a variable in action class and model-driven bean object.</p>
  
  <pre><code>public class PaymentGateWayAction extends ActionSupport implements ModelDriven&lt;PaymentResponseDTO&gt; {
      private String searchKey;
      private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO();
      // ...
  }
  </code></pre>
  
  <p><code>searchKey</code> is also a variable in <code>PaymentResponseDTO</code>.</p>
  
  <p>I need to access <code>searchKey</code> from the action class and modeldriven bean based on some conditions. Having varible with same name is bad. But The above one is already developed. If I do any modification in Java file, I need to do many modifications which are difficult.</p>
  
  <p>Now I need to access the action class variable. I tried to access the variable from action class in the follwing way:</p>
  
  <pre><code>&lt;s:hidden id="searchKey" name="searchKey" value="%{searchKey}"/&gt;
  </code></pre>
  
  <p>But it is returning null values.</p>
  
  <p>I have below code also:</p>
  
  <pre><code>this.setSearchKey("somevarible");
  </code></pre>
  
  <p>Please suggest where the wrong is going on</p>
  
  <p><strong>struts.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;action name="atomResponse" class="com.PaymentGateWayAction" method="atomPaymentResponse"&gt;
    &lt;result name="success" type="tiles"&gt;paymentGateWayResponse&lt;/result&gt;
      &lt;result name="failure" type="tiles"&gt;paymentGateWayResponseError&lt;/result&gt;
    &lt;/action&gt;
  </code></pre>
  
  <p><strong>tiles xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;definition name="paymentGateWayResponse" extends="b2cHome"&gt;
      &lt;put-attribute name="body" value="agent_b2c/b2c_paymentGateWayResponse.jsp" /&gt;
  &lt;/definition&gt;
  </code></pre>
  
  <p>In <code>b2c_paymentGatewayResponse.jsp</code> the hidden field code is present.</p>