aspose file tools*
The moose likes Servlets and the fly likes Why are servlets serialized? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why are servlets serialized?" Watch "Why are servlets serialized?" New topic
Author

Why are servlets serialized?

thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
Why are servlets serialized?
thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
Nobody has answered for this question so far..
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

What do you mean by serialized?


Groovy
Chad Patrick
Greenhorn

Joined: Feb 01, 2003
Posts: 11

I cant provide a solid answer on this, but I went to search google because I was curious about it to and on the 20th or so page of results, this link came back:
http://www.isse.gmu.edu/~lili/642/Servlets.pdf
IF you search that document for "serialized", it makes reference to if more service requests are recieved than the connection pool allows, then the requests are serialized (following this particular model). I dont know if this has any relevance to your question, but its an instance where servlet serialization is used..
Chad Patrick
Greenhorn

Joined: Feb 01, 2003
Posts: 11

I think i probably made that previous answer more complicated than it is...
I think servlets are serialized so you can save their state in the destoy() method when it unloads.. and reload it in the init().
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I guess thomas is talking about about single threaded access. If you do not want your servlet to be accessed by a single thread and multiple you use the SingleThreadModel.

The interface SingleThreadModel is an empty i/f and will be deprecated in servlet 2.4 spec.
Kalyan Ayyagari
Greenhorn

Joined: Aug 04, 2003
Posts: 5
>>I think servlets are serialized so you can save their state in the destoy
>>() method when it unloads.. and reload it in the init().
I thought that serialization is required only we are sending data (or information) to another machine because the references in the source machine may not make sense in the destination machine.
But in the above case (unload and reload) the servlet exists on the same JVM.
Please let me know if I'm wrong.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
The abstract class javax.servlet.GenericServlet implements Serializable - presumably to allow for saving the state of a servlet instance under some circumstances. Of course for serialization to succeed, all instance variables would have to be serializable too.
I have never heard of a circumstance in which this capability is actually used.
Bill
Syil Choi
Greenhorn

Joined: Jul 02, 2002
Posts: 1

[ August 11, 2003: Message edited by: Syil Choi ]
 
jQuery in Action, 2nd edition
 
subject: Why are servlets serialized?