tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: [OT] When will SingleThreadModel be removed?
Date Tue, 01 Mar 2011 21:28:12 GMT
Hash: SHA1


On 2/24/2011 3:34 PM, Caldarale, Charles R wrote:
>> From: Tony Anecito [] 
>> Subject: When will SingleThreadModel be removed?
>> When do you think SingleThreadModel will go from 
>> deprecated to being gone?
> Not soon enough.


Oddly enough, while the Servlet Spec has gone from tolerating the STM
for servlets to being anti-STM, the Struts folks have gone the opposite
direction. It used to be (Struts 1) that you'd write an "action", which
is analogous to a servlet, and it would be called from Struts's front
controller (which was a servlet).

In Struts 2, they have deprecated that model in favor of one where the
"action" actually gets instantiated solely for the purposes of handling
a single request. This allows action objects to store their own internal
state in members instead of using the request scope or local variables.
It also allows the framework to do all kinds of wonderful things such as
dependency injection, request parameter delivery, etc. all while being
independent of the Servlet API itself. That means it's easier to write
unit tests, re-use code, etc.

Given that the Servlet spec has also changed models from using
Servlet.init for initialization code to using ServletContextListener, I
would think that a model for servlet dispatching that looked like this
wouldn't be too bad:

Class servletClass = /* determine class to handle request */
Servlet servlet = servletClass.newInstance();

servlet.service(request, response);

That's essentially what STM does, anyhow (if you ignore servlet instance
pooling, which I suspect most containers provide).

The problem, I guess, is that the same old, funky code that uses STM
also uses Servlet.init to set up the servlet context.

It just seems like the "current" Servlet model is rather dated, IMHO,
with respect to Struts's model. When I read about how Struts 2 does
things, I found myself saying "why wasn't it always this way?".

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message