tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Moore" <>
Subject RE: Single Servlet vs Multiple Servlet
Date Fri, 24 Jan 2003 16:19:58 GMT
> -----Original Message-----
> From: Robert Simmons [] 
> Sent: Friday, January 24, 2003 11:09 AM
> To: Tomcat
> Subject: Single Servlet vs Multiple Servlet 
> Greetings, 
> I am developing a pretty rich web application that will be 
> served by Java servlets. The question to me right now is If I 
> want to go with single or multiple servlets. 
> In all there will be about 50 commands that can be done to 
> this servlet. If I put them all in one file it would violate 
> my sense of object oriented engineering. So I thought of 
> either making the various commands actually be in different 
> classes and the servlet routing the requests to the proper 
> command.

You should take a look at Struts, which is a framework to do exactly

> The alternative is to make individual command 
> servlets that have a common base class and sit on separate URLs. 
> The problem with option two is that the servlet connects to 
> EJB on the back end and could potentially hold onto allot of 
> resources. The problem with option two, possibly, is 
> federation. If there are hundreds of requests coming, will 
> tomcat federate the servlet or pipe everything through one hole? 

Tomcat (and any servlet container, for that matter) will use a single
servlet instance, but multiple threads.  So it can service many requests
at once, but to make your servlet thread-safe, you can't store any
request-specific state in instance variables.  This is true regardless
of which approach you take.

I personally prefer the single-servlet, multiple command class approach.
I use Struts, which takes care of the basics for you.

Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message