Add exo4 missing bits and exo10 code.
[TD_webapps.git] / ROOT / exo10 / WEB-INF / src / date / Date.java
1 package date;
2
3 // Import required java libraries
4 import java.io.*;
5 import javax.servlet.*;
6 import javax.servlet.http.*;
7 import javax.servlet.annotation.WebServlet;
8
9 @WebServlet(name="Date", urlPatterns={"/Date"})
10 // Extend HttpServlet class
11 public class Date extends HttpServlet {
12
13 private java.util.Date d;
14 private Integer count;
15
16 public void init() throws ServletException {
17 // Do required initialization
18 d = new java.util.Date(); // Date at init time, do not change
19 count = 0;
20 }
21
22 public void doGet(HttpServletRequest request, HttpServletResponse response)
23 throws ServletException, IOException {
24
25 // Set response content type
26 response.setContentType("text/html");
27
28 // Actual logic goes here.
29 count++;
30 PrintWriter out = response.getWriter();
31 out.println("<html>");
32 out.println("<body>");
33 out.println("Date " + d.toString());
34 out.println("<br>");
35 out.println("GET call number " + count);
36 out.println("</body>");
37 out.println("</html>");
38 }
39
40 public void destroy() {
41 count = 0;
42 }
43 }