You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lind Jürgen <Ju...@iteratec.de> on 2001/02/14 11:18:00 UTC
Avoid JSP caching by the browser
Hi there,
I have the following problem: in order to prevent the web-browser
from using cached versions of a jsp, we plan to add some unique
timestamp (which will actually be ignored by the jsp) to the url
that calls the jsp, e.g.:
<a href="/jsp/view.jsp?ts=<%= System.currentTimeMillis()%>">myjsp</a>
While this works fine when cookies are enabled, it fails when
cookies are disabled because it does not make use of the URL
rewriting capabilities of the Struts taglib.
Using the html:link tag, however, introduces the difficulty how to
dynamically add the timestamp. Using something like
<html:link href="/jsp/view.jsp?ts=<%=
System.currentTimeMillis()%>">myjsp</html:link>
fails as the Java Code will not get interpreted but it will be literally
appended to the URL, causing a Decode Error in the receiving JSP.
Has anyone experienced similar problems (with the web browser caching
jsp pages) and could offer some help or are there any suggestions wrt.
the above evaluation problem?
Regards
Jürgen
--
Dr. Jürgen Lind
iteratec GmbH Fon: +49 (0)89 614551-44
Inselkammerstrasse 4 Fax: +49 (0)89 614551-10
82008 Unterhaching Web: www.iteratec.de
Re: Avoid JSP caching by the browser
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Lind Jürgen wrote:
> Hi there,
>
> I have the following problem: in order to prevent the web-browser
> from using cached versions of a jsp, we plan to add some unique
> timestamp (which will actually be ignored by the jsp) to the url
> that calls the jsp, e.g.:
>
> <a href="/jsp/view.jsp?ts=<%= System.currentTimeMillis()%>">myjsp</a>
>
> While this works fine when cookies are enabled, it fails when
> cookies are disabled because it does not make use of the URL
> rewriting capabilities of the Struts taglib.
>
> Using the html:link tag, however, introduces the difficulty how to
> dynamically add the timestamp. Using something like
>
> <html:link href="/jsp/view.jsp?ts=<%=
> System.currentTimeMillis()%>">myjsp</html:link>
>
This fails because you cannot intermix constant text and runtime expressions
in a single attribute -- it has to be one or the other:
<html:link href='<%= "/jsp/view.jsp?ts=" + System.currentTimeMillis()
%>'>myjsp<html:link>
Note the use of single quotes around the entire expression so that the
parser doesn't get confused by the double quotes around Java strings.
>
> fails as the Java Code will not get interpreted but it will be literally
> appended to the URL, causing a Decode Error in the receiving JSP.
>
> Has anyone experienced similar problems (with the web browser caching
> jsp pages) and could offer some help or are there any suggestions wrt.
> the above evaluation problem?
>
>
> Regards
>
> Jürgen
>
Craig McClanahan
Re: Avoid JSP caching by the browser
Posted by Rob Leland <Ro...@freetocreate.org>.
Use the Action.saveToken(), Action.resetToken(),
Action.isTokenValid() for
form transactions. This does exactly what you want.
see
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg02888.html
for the thread that discusses this.
Lind Jürgen wrote:
>
> Hi there,
>
> I have the following problem: in order to prevent the web-browser
> from using cached versions of a jsp, we plan to add some unique
> timestamp (which will actually be ignored by the jsp) to the url
> that calls the jsp, e.g.:
>
> <a href="/jsp/view.jsp?ts=<%= System.currentTimeMillis()%>">myjsp</a>
>
> While this works fine when cookies are enabled, it fails when
> cookies are disabled because it does not make use of the URL
> rewriting capabilities of the Struts taglib.
>
> Using the html:link tag, however, introduces the difficulty how to
> dynamically add the timestamp. Using something like
>
> <html:link href="/jsp/view.jsp?ts=<%=
> System.currentTimeMillis()%>">myjsp</html:link>
>
> fails as the Java Code will not get interpreted but it will be literally
> appended to the URL, causing a Decode Error in the receiving JSP.
>
> Has anyone experienced similar problems (with the web browser caching
> jsp pages) and could offer some help or are there any suggestions wrt.
> the above evaluation problem?
>
> Regards
>
> Jürgen
>
> --
> Dr. Jürgen Lind
> iteratec GmbH Fon: +49 (0)89 614551-44
> Inselkammerstrasse 4 Fax: +49 (0)89 614551-10
> 82008 Unterhaching Web: www.iteratec.de