/*
/  File: WriteFileServlet.java
/  Autore: Michele Milani
/  Data: 2001-12-08
/  Versione: 1.0
*/

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DateServlet extends HttpServlet {
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		try {
			Date now = new Date();
			
			PrintWriter dateWriter = new PrintWriter(new FileWriter("../webapps/test/date.html"), true);
			dateWriter.println(now);
			dateWriter.println("<br>");
			dateWriter.println("<a href=\"servlet/DateServlet\">Update</a>");
			dateWriter.close();
			
			response.setContentType("text/html");
			PrintWriter out = response.getWriter();
			out.println(now);
			out.println("<meta http-equiv='refresh' content='3; url=\"/test/date.html\"'></meta>");
			
		} catch(Exception ex) {
			PrintWriter errorWriter = new PrintWriter(new FileWriter("../webapps/bib/error.txt"), true);
			ex.printStackTrace(errorWriter);
			errorWriter.close();
		}
	}
	
}