Hi everyone!
I'm new at the servlet technology and this list too, and my english is
terrible and I've got a question, so it isn't easy for me (and for You).
Well...
I've got a servlet. It works as a front component (it communicates with
applet clients), it forwards requests to Handler classes (not to other
servlets), through a Broker class. When the servlet starts I have to store
some servlet-wide (web application-wide) data, so I made a class called
Manager. The Manager has only static members (fields, methods). In the
servlets init method I call the Manager's static init method, which make an
instance from the Broker class, and stores it in a private static variable.
In the init method I also make a mapping in a hashtable that requests from
/foo/bar will be handled by a class called FooBarHandler. Example:
broker.registerHandler("/foo/bar",new FooBarHandler()). In the
registerHandler method: hashtable.put(name,handler).
In the doPost method I simply call Manager.getBroker().forward(request).
Then the Broker calls the FooBarHandler's handle method.
In the Manager's init method I make instances from other classes too, for
example a Logger class. The reason is that I don't want to pass the
servletcontext as a parameter to all my methods just to implement a log. I
simply call Manager.writeLog() from any method of any class.
And finally my question: Is it a good design pattern or is completely wrong?
What are the drawbacks? What can I do (make?) better?
Thanks for the patience.
Regards
Gábor
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html