Remarks
The first time I point my browser at this servlet (e.g. at
http://sirah.csit.fsu.edu:8081/dbc/servlet/Counter
), I get a response page containing the message:
This servlet has been accessed 0 times
Each time I reload the URL, the count increases.
Since count is an instance variable of the class, this illustrates that indeed only a single instance of Counter is created.
This servlet is not completely reliable, because it is possible to have concurrent requests in different threads. The instance variable count is shared by threads. This could lead to problems of interference.