title: Prevent JSP from caching values
body: <p>I am facing problem of caching when using JSP. My application is made up of struts and jsp.
  Practically in my application struts action class and JSP page is being used for adding and editing data.</p>
  
  <p>The sequence of action that takes place are as follow:</p>
  
  <ol>
  <li>User login into application</li>
  <li>User visits the JSP page(PreNeed.jsp) containing form to fill up.</li>
  <li>User fill in details and clicks on save button.</li>
  </ol>
  
  <p>Now assume user had checked "Pre-Need Serviced" radio button and submitted form as shown in below screenshot.</p>
  
  <p>But next time when user goes and tries to fill in form and clicks on save button then it automatically tries to save as "Pre-Need Serviced" even though user is not touched that section.</p>
  
  <p>I feel page is caching values.</p>
  
  <p>I tried putting below scriplet in JSP page:</p>
  
  <pre><code>&lt;%        
      response.setHeader("Pragma", "No-cache");
      response.setHeader("Cache-Control", "no-cache");
      response.setDateHeader("Expires", 0);
  %&gt;
  </code></pre>
  
  <p>But does not worked out. Is there any specific position this code needs to be placed ?</p>
  
  <p>EDIT:
  Here is my JSP code</p>
  
  <pre><code>&lt;td id="_preneedStatus"&gt;
      &lt;logic:notEqual name="preNeed" property="posted" value="1"&gt;
          &lt;html:radio value="Active" name="preNeed" property="preneedStatus"/&gt;
          &lt;font face="Arial" size="2"&gt;Pre-Need Active&lt;/font&gt;&lt;br&gt;
      &lt;/logic:notEqual&gt;
      &lt;html:radio value="Serviced" name="preNeed"  property="preneedStatus"/&gt;
      &lt;font face="Arial" size="2"&gt;Pre-Need Serviced&lt;/font&gt;&lt;br&gt;
      &lt;logic:equal name="accoutDescDisplay" scope="session" value="display"&gt;
          &lt;font face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Service Date:&amp;nbsp;&lt;/font&gt;
                  &lt;html:text size="10" name="preNeed" property="serviceDate" onblur="setDispositionDate();" onfocus="focusDateEdit(this);" /&gt;
                  &lt;fdms:FDMSDate fieldID="serviceDate1" javascriptFormField="document.forms[0].serviceDate"&gt;&lt;/fdms:FDMSDate&gt;
          &lt;br/&gt;       
      &lt;/logic:equal&gt;
      &lt;logic:notEqual name="preNeed" property="posted" value="1"&gt;
          &lt;html:radio value="Cancelled"  name="preNeed" property="preneedStatus"/&gt;
          &lt;font face="Arial" size="2"&gt;Pre-Need Cancelled&lt;/font&gt;
      &lt;/logic:notEqual&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p><strong>Browser For testing:</strong> Firefox, Chrome</p>
  
  <p><strong>Framework:</strong> Struts 1.2</p>
  
  <p><strong>Server:</strong> Wildfly 9.0.1.Final(JBoss)</p>
  
  <p>Please guide me on the same.
  <a href="https://i.stack.imgur.com/jJenS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jJenS.jpg" alt="enter image description here"></a></p>