Reputation: 847
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.
The sequence of action that takes place are as follow:
Now assume user had checked "Pre-Need Serviced" radio button and submitted form as shown in below screenshot.
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.
I feel page is caching values.
I tried putting below scriplet in JSP page:
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
But does not worked out. Is there any specific position this code needs to be placed ?
EDIT: Here is my JSP code
<td id="_preneedStatus">
<logic:notEqual name="preNeed" property="posted" value="1">
<html:radio value="Active" name="preNeed" property="preneedStatus"/>
<font face="Arial" size="2">Pre-Need Active</font><br>
</logic:notEqual>
<html:radio value="Serviced" name="preNeed" property="preneedStatus"/>
<font face="Arial" size="2">Pre-Need Serviced</font><br>
<logic:equal name="accoutDescDisplay" scope="session" value="display">
<font face="Arial" size="2"> Service Date: </font>
<html:text size="10" name="preNeed" property="serviceDate" onblur="setDispositionDate();" onfocus="focusDateEdit(this);" />
<fdms:FDMSDate fieldID="serviceDate1" javascriptFormField="document.forms[0].serviceDate"></fdms:FDMSDate>
<br/>
</logic:equal>
<logic:notEqual name="preNeed" property="posted" value="1">
<html:radio value="Cancelled" name="preNeed" property="preneedStatus"/>
<font face="Arial" size="2">Pre-Need Cancelled</font>
</logic:notEqual>
</td>
Browser For testing: Firefox, Chrome
Framework: Struts 1.2
Server: Wildfly 9.0.1.Final(JBoss)
Upvotes: 2
Views: 3313
Reputation: 542
I'm not sure what you've actually tried up to this point, and I'm also not sure what browser you're working in, but have you tried anything along these lines in your JSP file:
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>
It seems to be a common answer to caching issues. However, this will most likely also get rid of all caching, so it's probably not exactly what you're looking for.
Sources:
Upvotes: 1