Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
152
Chapter 7 Generating the Server Response: HTTP Response Headers
Refresh
This header indicates how soon (in seconds) the browser should ask for
an updated page. For example, to tell the browser to ask for a new copy
in 30 seconds, you would specify a value of 30 with
response.setIntHeader("Refresh", 30)
Note that
Refresh
does not stipulate continual updates; it just speci
fies when the next update should be. So, you have to continue to sup
ply
Refresh
in all subsequent responses, and sending a 204 (
No
Content
) status code stops the browser from reloading further. For an
example, see Section 7.3 (Persistent Servlet State and Auto Reloading
Pages).
Instead of having the browser just reload the current page, you can
specify the page to load. You do this by supplying a semicolon and a
URL after the refresh time. For example, to tell the browser to go to
http://host/path
after 5 seconds, you would do the following.
response.setHeader("Refresh", "5; URL=http://host/path")
This setting is useful for splash screens, where an introductory image
or message is displayed briefly before the real page is loaded.
Note that this header is commonly set by
CONTENT="5; URL=http://host/path">
in the
HEAD
section of the HTML page, rather than as an explicit header
from the server. That usage came about because automatic reloading or
forwarding is something often desired by authors of static HTML pages.
For servlets, however, setting the header directly is easier and clearer.
This header is not officially part of HTTP 1.1 but is an extension sup
ported by both Netscape and Internet Explorer.
Retry After
This header can be used in conjunction with a 503 (
Service Unavail
able
) response to tell the client how soon it can repeat its request.
Server
This header identifies the Web server. Servlets don't usually set this; the
Web server itself does.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved