Yurttas/PL/OOL/Java/F/08/03/01/00/CounterServlet00.java

From ZCubes Wiki
Jump to navigation Jump to search
 1/**
 2 *  Copyright(C) 2000
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *   @date   : June 1, 2000.
11 *   @author : Salih Yurttas.
12 */
13
14
15import javax.servlet.*;
16
17import java.io.*;
18
19import java.util.Hashtable;
20import java.util.Date;
21
22public class CounterServlet00 extends GenericServlet {
23
24  static int count = 0;
25  static Date start = new Date();
26
27  public void service(ServletRequest request,
28                      ServletResponse response)
29   throws ServletException, IOException
30  {
31    int temp;
32
33    response.setContentType("text/plain");
34
35    PrintStream pS = new PrintStream(response.getOutputStream());
36
37    synchronized(this) {
38      temp = count++;
39    }
40
41    pS.println("This servlet has been accessed " +
42               temp +
43               " times since " +
44               start);
45  }
46
47}