To elaborate, a logon servlet might accept a paramter which means display the username / password and submit button initially. Then when someone clicks submit the same servlet it called with a parameter that means, check the credentials and either display - "logon succeeded" or "logon failed".
I've not found an example of this yet, so it may be bad practice. If so please explain why.
Here is what I think about servlets.
Servlets should be used for delegating calls to business logic sitting in different classes or forwarding to views / jsp's.
It would not be a bad idea to put logic specific to a particular functional module in one servlet.If some major changes to the module happens then a new servlet can be constructed and the previous version may be replaced.
But the class should not grow too large or else maintaining might be difficult in future.
Struts has a similar Action known as DispatchAction for this .
Consider defining the worker class based on an interface so that the servlet only deals with interface methods - makes it easy to plug in an alternate worker based on whatever...
If you can design the worker class so that it can be tested outside the servlet environment, even better!
As William said, it is better to break the different behaviors into different classes (commands or actions) and have the servlet do nothing more than delegate the task to these commands.
Doing so makes things a lot easier to test and maintain.
Originally posted by Bear Bibeault:
Perhaps the time has come to make FrontMan available. I was going to wait until I had chance to write a JR Journal on its design, but that's probably not going to happen soon. Watch the Blatant Advertising forum late this evening or perhaps tomorrow...
Looking forward to it.