This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why is HttpServlet Serializable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why is HttpServlet Serializable?" Watch "Why is HttpServlet Serializable?" New topic

Why is HttpServlet Serializable?

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Hi Friends,

Why is HttpServlet (or GenericServlet) Serializable?

Same for HttpSessionBindingEvent, HttpSessionEvent, ServletContextEvent, ServletContextAttributeEvent.

They seem to live forever in the container, never travel outside of it. I have not noticed they have to be persisted either. So why is the need for serialization?

I appreciate your opinions.

We must know, we will know. -- David Hilbert
Joan Horta Tosas
Ranch Hand

Joined: Feb 01, 2007
Posts: 59
I'm not sure, but I think it's to allow the container to persist their state and "suspend/resume" them according to their use, pooling, etc... I can't think of another reason.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

And clustering
It is sorta covered in the JavaRanch Style Guide.
subject: Why is HttpServlet Serializable?
Similar Threads
Why HttpServlet implements Serializable interface
is Serialization Inherited
GenericServlet Vs HttpServlet
extending a class which implements Serializable
HttpServlet implementing Serializable