Christian's suggestion below is the *best* way to do this. However very
occasionally it won't work, due perhaps to an evil proxy server. In this
case a hack is possible, when setting location.href append a bogus and
random parameter on the end of the url to defeat the proxies page
recognition, forcing it to allow you to fetch a new page.


> -----Original Message-----
> From: Christian Bollmeyer (GMX) [SMTP:[EMAIL PROTECTED]]
> Sent: 09 January 2003 10:34
> To:   [EMAIL PROTECTED]
> Subject:      Re: Location.href
>
> Am Donnerstag, 9. Januar 2003 16:36 schrieb KEITH KOSMICKI:
>
> > I have a button on a page that uses location.href to go to other pages.
> > One of these buttons options goes to the previous page.
> > However, it loads the page out of history rather than loading a new page
> > from the server.url Replace does not work and gives syntax error and
> other
> > options so far load a blank page.  Any suggestions.
>
> Obviously, the previous page was cached. For dynamic pages that should
> be requested again each time, you have to tell the browser | proxy that it
> shouldn't use the cache. Unfortunately, the mechanism is not standardized,
> but putting the following lines in your JSP page somewhere before
> sending body content should normally suffice:
>
> <%
>   response.addHeader("Pragma", "no-cache");
>   response.setHeader("Cache-control", "no-cache");
>   response.setDateHeader("Expires", 0);
> %>
>
> There is a fourth possible line which I saw once but don't remember
> right now, but that's kind of esoteric anyway. As this is a common task,
> you can also write a handy little tag for such stuff, as described in
> O'Reilly's JSP book, for example (www.TheJSPBook.com). If the
> page in question is static HTML, those lines should go into <META>
> tags in the <HEAD> section of your page.
>
> HTH,
>
> -- Chris (SCPJ2)
>
> OK, I'll also add the code for my own solution. Most parts are
> generated by Sun ONE Studio, as I was lazy and used the
> wizard, so the code is kind of verbose. But still. Here it comes:
>
> package de.christianbollmeyer.tags;
>
> import javax.servlet.jsp.tagext.TagSupport;
> import javax.servlet.jsp.JspException;
> import javax.servlet.jsp.PageContext;
> import javax.servlet.ServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.jsp.tagext.BodyTagSupport;
> import javax.servlet.jsp.tagext.BodyContent;
> import javax.servlet.jsp.JspWriter;
> import java.io.PrintWriter;
> import java.io.IOException;
> import javax.servlet.jsp.tagext.Tag;
> import javax.servlet.jsp.tagext.IterationTag;
> import javax.servlet.jsp.tagext.BodyTag;
>
> public class NoCacheTag extends TagSupport {
>
>     public NoCacheTag() {
>         super();
>     }
>
>     // doStartTag()
>     public void otherDoStartTagOperations()  {}
>     public boolean theBodyShouldBeEvaluated()  {
>         return false;
>     }
>
>     // doEndTag()
>     public void otherDoEndTagOperations()  {
>         HttpServletResponse rsp
>         = (HttpServletResponse)(Object) pageContext.getResponse();
>         rsp.addHeader("Pragma", "No-cache");
>         rsp.addHeader("Cache-Control", "no-cache");
>         rsp.addDateHeader("Expires", 0L);
>     }
>
>     public boolean shouldEvaluateRestOfPageAfterEndTag()  {
>         return true;
>     }
>
>     // doAfterBody()
>     public boolean theBodyShouldBeEvaluatedAgain()  {
>         return false;
>     }
>
>     /** .//GEN-BEGIN:doStartTag
>      *
>      * This method is called when the JSP engine encounters the start tag,
>      * after the attributes are processed.
>      * Scripting variables (if any) have their values set here.
>      * @return EVAL_BODY_INCLUDE if the JSP engine should evaluate the tag
>       body, otherwise return SKIP_BODY.
>      * This method is automatically generated. Do not modify this method.
>      * Instead, modify the methods that this method calls.
>      *
>      */
>     public int doStartTag() throws JspException, JspException {
>         otherDoStartTagOperations();
>
>         if (theBodyShouldBeEvaluated()) {
>             return EVAL_BODY_INCLUDE;
>         } else {
>             return SKIP_BODY;
>         }
>     }//GEN-END:doStartTag
>
>     /** .//GEN-BEGIN:doEndTag
>      *
>      *
>      * This method is called after the JSP engine finished processing the
> tag.
>      * @return EVAL_PAGE if the JSP engine should continue evaluating the
> JSP
>       page, otherwise return SKIP_PAGE.
>      * This method is automatically generated. Do not modify this method.
>      * Instead, modify the methods that this method calls.
>      *
>      */
>     public int doEndTag() throws JspException, JspException {
>         otherDoEndTagOperations();
>
>         if (shouldEvaluateRestOfPageAfterEndTag()) {
>             return EVAL_PAGE;
>         } else {
>             return SKIP_PAGE;
>         }
>     }//GEN-END:doEndTag
> }
>
> > Best,
> >
> >
> > Keith E. Kosmicki
> > Applications Consultant
> > State of IL Human Services
> > STL Technology Partners
> >
> >
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set
> > JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found
> at:
> >
> >  http://archives.java.sun.com/jsp-interest.html
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.jsp
> >  http://www.jguru.com/faq/index.jsp
> >  http://www.jspinsider.com
>
> ==========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
--

It is the strict policy of Truworths that its e-mail facility and all
e-mail communications emanating therefrom, should be utilised for
business purposes only and should conform to high professional and
business standards.   Truworths has stipulated certain regulations in
terms whereof strict guidelines relating to the use and content of
e-mail communications are laid down. The use of the Truworths e-mail
facility is not permitted for the distribution of chain letters or
offensive mail of any nature whatsoever.   Truworths hereby distances
itself from and accepts no liability in respect of the unauthorised
use of its e-mail facility or the sending of e-mail communications
for other than strictly business purposes.   Truworths furthermore
disclaims liability for any  unauthorised instruction for  which
permission was not granted.    Truworths Limited accepts no liability
for any consequences arising from or as a result of reliance on this
message unless it is in respect of bona fide Truworths business for
which proper authorisation has been granted.

Any recipient of an unacceptable communication, a chain letter or
offensive material of any nature is requested to notify the Truworths
e-mail administrator ([EMAIL PROTECTED]) immediately in order that
appropriate action can be taken against the individual concerned.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to