Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes why do genericServlet and HttpServlet implements serizable inferface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "why do genericServlet and HttpServlet implements serizable inferface" Watch "why do genericServlet and HttpServlet implements serizable inferface" New topic
Author

why do genericServlet and HttpServlet implements serizable inferface

Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
Hi

Can someone explain in details why do genericservlet and httpservlet implements serizable interface?

I just read that servlet engine can hibernate the servlet to store the state of the servlet or to duplicate the servlet instance for better load balancing.

Is there any pitfall of this?
How developer's work effected by this functionality of the servlet engine?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Originally posted by bittoo garg:
Is there any pitfall of this?
How developer's work effected by this functionality of the servlet engine?

It's best not to be storing user specific state in a servlet in the first place as multiple users will access it. There could be state that applies to everyone - such as a data access object reference. In this case, you would want the data to be be serializable if your server implements hibernation.

I don't see the value of duplicating the servlet. The server could just create a new one.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: why do genericServlet and HttpServlet implements serizable inferface
 
Similar Threads
Why both GenericServlet and HttpServlet implements Serializable interface ?
Why HttpServlet implements Serializable interface
init missing in servlet
types of servlets
need advice