It's not a secret anymore!
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
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
I agree. Here's the link:
subject: Why is HttpServlet Serializable?
It's not a secret anymore!