Zeng writes:
> As to implementing Cache Control in JSP (or servlet),
> at least the following two paragraphs of sample codes
> can always be found:
>
> 1, Using JAVA methods, like (in JSP or in servlet)
> [... to set headers ...]
> 2, Using HTML tags, like
> [... to set head META tags ...]
>
> Will anyone please explain as clearly as possible the difference
> between them above ? Especially, do browsers (such as IE and NN)
> differ in any way when handling the same resulted HTML file?
The chief difference between the two approaches is where and how
the settings are communicated. In the first approach, the settings
are communicated as headers in the reqeust/response messages the
browser and server exchange. In the second approach, the settings are
embedded in the actual page text (as part of the <HEAD> section of the
page) and the browser inteprets it.
The earlier browsers are probably less likely to notice the META
tags, but I can't give you exact version numbers and I can't tell you
how the different browsers will react to the different headers. All I
can say is that I'm fairly sure, from experience, that they won't all
react the same way.
I strongly recommend that any web developer obtain a simple proxy
server (one I used in the past on a MS-Windows box was HttpProxySpy,
but I hear it's no longer available) install it on your machine, point
your browser at it, and use it to monitor how your server and browser
really communicate. Not only will you have a much easier time
figuring out what's going on, you'll start to learn how things really
work.
In general, browsers and http servers communicate by sending each
other MIME-encoded messages. Browsers send single-line and multi-line
mimes to the server. The single-line mimes cover most of the standard
GET requests. The multi-line mimes cover POSTs and FORM/MULTIPART
requests.
Servers send single-line mimes to the browser. As far as I know
this isn't part of the standard, it's just that most/all browsers
aren't designed to handle multi-line mimes. For that matter, I don't
know if any HTTP servers are even capable of sending multi-line mimes.
The allowable headers are mostly defined by the mail headers in:
RFC822: Standard for ARPA Internet Text Messages
as well as the MIME headers in:
RFC1341: Multipurpose Internet Mail Extensions (MIME)
RFC1521: Multipurpose Internet Mail Extensions (MIME)
Not to mention whatever else the w3c (http://www.w3c.org) has
thrown into the mix.
If you set up a proxy and look at the messages flowing between
your browser and the http server, you'll see that the requests from
your browser are mostly a single line along the lines of:
Request=GET http://www.w3c.org
However, the response usually includes several lines - first some
header lines, then the body of the document. Unless you see what the
headers are, and pay attention to how your browser reacts to them, and
watch not just the individual requests but the flow of requests, you
won't really know what's going on.
Steven J. Owens
[EMAIL PROTECTED]
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets