1

Why is RemoteServiceServlet Serializable? I can't think of a situation where I want to serialize a Servlet.

If I know that I will never have a need to to so, shall I suppress the warning (The serializable class does not declare a static final serialVersionUID)?

helpermethod
  • 59,493
  • 71
  • 188
  • 276
  • 3
    See http://stackoverflow.com/questions/179743/why-does-httpservlet-implement-serializable – matt b Mar 30 '11 at 13:49

2 Answers2

3

This has nothing to do with GWT. The base class for all servlets (javax.servlet.GenericServlet) is already marked as serializable. The reason for this is that a servlet engine may decide to persist the instance state of a servlet class. I am not sure if any container actually implements the functionality, but it is allowed according to the J2EE specification.

jarnbjo
  • 33,923
  • 7
  • 70
  • 94
2

There's a nice article on the serialVersionUID on http://www.javaworld.com/javaworld/javaqa/2003-06/02-qa-0627-mythser.html

The servlet needs to be serializable because when in a distributed environment, it can be serialized and deserialized by the container.

mmjmanders
  • 1,533
  • 2
  • 13
  • 32