I think everyone here caught a part of it. I believe we have three different situations where a helper class may be used, and therefore several ways (
patterns?) of implementing a solution. Anyone/everyone please correct me if I'm slightly misguided (or just flippin' wrong!).
Case 1
---------
Helper is doing processing related to all users of the system.
Example: Hit counter.
Solution: Use a Helper with a static member variable, and make the method used to change the variable synchronized in order to make it safe and produce correct results. An optional implementation is rather than making the Helper a member variable of the servlet, create it in the init() but place it in the ServletContext, and retrieve it in the doXXX processing. This would allow the Helper to be accessed by other servlets/JSPs as well.
Case 2
---------
Helper performs simple logic or utility processing on request input.
Example: Form Validation.
Solution: Instantiate a new Helper object in the doXXX method and use it as needed. Do not use static member variables in it.
Case 3
---------
Helper performs complex logic or utility processing on request input that involves creation of other objects to aid processing, or Helper needs to be part of a framework or extensible class hierarchy that supports/enforces certain functionality or the particular Helper do be used is picked dynamically based on request input or session/application state.
Example: Form validation with database update using a logging class and a database connection factory.
Solution: Write a Helper factory that creates and/or pools Helper objects. Additional objects that support the Helper (HelperHelpers?) may also need to be retrieved from a factory depending on requirements.