[plt-scheme] difference between stateful and stateless servlets, and which to use

From: keydana at gmx.de (keydana at gmx.de)
Date: Fri May 22 16:10:16 EDT 2009

Hi Jay, hi Robby,

thanks a lot for your extremely quick and helpful responses! Now I see  
I really was quite wrong! I don't know if it's from having web  
development experience mainly with Java, or because I chose snooze  
explicitly for the "Active Record" pattern (thanks to a hint some time  
ago here on the list :-) ) - but really I was somehow associating  
"state" with the active record objects...

Now with your explanation, on the other hand, it's very clear that  
it's about the storage of the continuations! Perhaps it might really  
make sense to put this directly into the documentation, - if you ask  
me, your explanation is very clear and concise Jay!

Also Robby, I would agree that "stateful" and "stateless" are not so  
helpful as names. Ah yes - I think I was vaguely thinking of a  
difference similar to stateless and stateful EJB's maybe. To me as a  
layperson scheme user, the real difference between both forms as I  
learned it now would perhaps not even make it necessary to have such a  
big opposition - where the continuations are stored sounds like a  
rather "technical" matter to me, something like a configuration issue  
(but also here again I admit I'm spoiled, remembering now that Tomcat  
has such a configuration thing about where users are stored...).

I hope this was not too much of alluding to Java things :-;  - I just  
tried to understand myself why I was so completely mistaken, and  
perhaps other scheme newbies with similar background might also be, so  
it could make sense to adapt the documentation perhaps.


Am 22.05.2009 um 21:38 schrieb Jay McCarthy:

> Hi Sigrid,
> Perhaps we can figure out a better explanation for the documentation
> after I test it out on you.
> The only difference between stateful and stateless servlets is how
> they handle the continuations that are executed when you browse to
> URLs.
> Stateful servlets store those continuations in a hash-table in the
> server's memory.
> Stateless servlets give those continuations to "stuffers" which
> "stuff" them into the URLs themselves. In most cases this means
> actually serializing the continuation into a string that is included
> in the URL. However, with the hash-stuffer, it means putting the
> continuation on disk and a reference in the URL.
> All other state... whether that be database connections, images, or
> floating point numbers... that are not part of the continuation are in
> the server instance.
> Ceteris paribus, you want stateless servlets because they use less
> memory on the server. However, the stateless language imposes certain
> constraints on you, so it is not always an option.
> Jay
> On Fri, May 22, 2009 at 3:33 PM, keydana at gmx.de <keydana at gmx.de>  
> wrote:
>> Hi all,
>> to be honest, from the documentation it is not clear to me what the
>> difference between stateful and stateless servlets is, and which I  
>> should
>> use for my purpose. If I had to make a guess, I would perhaps  
>> assume that
>> with stateful servlets, state is kept in memory between requests,  
>> whereas
>> with stateless ones it would be always directly written somewhere,  
>> with the
>> help of "stuffers"  - is this at least a littel correct?
>> I 'd be very grateful for a short explanation of the real meanings,  
>> and also
>> perhaps a hint which to use. I plan to write a simple web  
>> application, using
>> snooze for the database handling. Up till now I'd imagined  
>> triggering the
>> database operations "manually"
>> (directly writing "save!" commands when necessary), but now I  
>> wonder if this
>> would be the way to go only with stateful servlets, whereas with  
>> stateless
>> ones I would pack this into a stuffer?
>> Thanks a lot in advance for any help,
>> Sigrid
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> -- 
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://teammccarthy.org/jay
> "The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.