How many actions should a servlet perform?

java, servlets

Solution

In Frameworks such as Struts there is one single servlet (although there could be multiple instances of it running). This servlet will handle requests for various URLs and pass them off the the relevant action handlers.

I only end up writing extra servlets for serving different content types such as an image rendering servlet.

Problem

I'm new to web development and am just wondering about best practices for java servlets. Should each servlet perform exactly one action, ie a servlet for login, a servlet for registration etc, or should I look to combine similar actions by passing a different parameter to tell the servlet which action to perform? Cheers

Original source