package testreloading; import javax.servlet.http.*; import java.io.*; import java.util.*; /** * Title: Test Document Reloading in IE and Mozilla * Description: * * Mozilla does not seem to control document reloading at all. IE has some quirks. * This project will be used to examine the behaviour of both browsers. * Document Reloading should be controlled by the document modification time. * If the document is newer than the client's most recent copy, then a new copy should be issued. * Otherwise, the server will issue a "not modified" status message and the client should display * the current copy that it has in the cache. * * Copyright: Copyright (c) 2001 * Company: ASC * @author Kevin Rogers * @version 1.0 */ public class TestServlet extends HttpServlet { Date servletStarted = new Date(); void blah(PrintWriter out) { for (int i = 0; i < 5; i++) out.println("

" + i + " Blah

"); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter out = response.getWriter(); response.setContentType("text/html"); System.out.println("********* DO GET ************"); out.println("Book Servlet"); out.println("

Test Document Reloading

"); out.println("

Do GET was last run at " + new Date()); out.println("

Page last modified at " + servletStarted.toString()); out.println("

Location 1

"); blah(out); out.println("

Location 2

"); blah(out); out.println(""); out.close(); } protected long getLastModified(HttpServletRequest req) { System.out.println(); System.out.println("Get Last Modified was last run at " + new Date()); long ifModifiedSince = req.getDateHeader("If-Modified-Since"); System.out.println("If modified since " + new Date(ifModifiedSince)); long lastModified = servletStarted.getTime(); return lastModified; } }