Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why are servlets serialized?

 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are servlets serialized?
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody has answered for this question so far..
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by serialized?
 
Chad Patrick
Greenhorn
Posts: 11
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ August 11, 2003: Message edited by: Syil Choi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic