Forums Register Login

Browser cacheing a page

+Pie Number of slices to send: Send
Hi,

I'm new to JSF and am having a problem.

I have two JSPs. The first, docMain.jsp, uses the h:commandLink target="_blank" to popup a new browser window to another JSP, docView.jsp.

In docMain.jsp I pass some parameters on the h:commandLink

<h:commandLink... target="_blank">
<f aram name="contentKey" value="#{Bean.contentKey}" />
</h:commandLink>

in the docView.jsp, I attempt to prevent the JSP from being cached

<%
response.setHeader("pragma", "no-cache");
response.setHeader("Cache-control", "no-cache, no-store, must-revalidate");
response.setHeader("Expires", "01 Apr 1995 01:10:10 GMT");

// then look for the content in the session using the request parameter
String contentKey = (String)request.getParameter("contentKey");
byte[] bytes = (byte[])session.getAttribute(contentKey);
response.getOutputStream().write(bytes);
response.getOutputStream().flush();

session.removeAttribute(contentKey);
%>

The above works fine in most cases except when the user does not close the existing child pop-up window. If he clicks on another link in the docMain.jsp (it's a list of documents in a DataTable component), the content from the previous link is displayed again.

My best guess is that the browser has cached the contents of the previous link. Since the URL does not change, it re-displays the cached page.

How do I fix this? redirect will not work since I rely upon the request parameter for the content key.

Is there a way to ask JSF to give me a unique URL or to append the content key to the URL?

Thanks,
-Ben
Tell me how it all turns out. Here is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1014 times.
Similar Threads
Question for double click issue regarding fileload with commandLink/CommandButton
problem with setContentType() method
Caching problem.
h:commandButton + actionListener
Servlet response already use stream, Writer not possible
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:24:47.