1 Reply Latest reply: Jul 19, 2012 2:39 PM by 900885 RSS

    why javax.servlet.http.HttpServlet is serializable ?

    929579
      As per serialization definition if super class implements java.io.Serializable then all sub classes are also get that behaviour.
      while coming to Servlets : javax.servlet.GenericServlet implents java.io.Serializable and this servlet class is super class for javax.servlet.http.HttpServlet and this also implemts java.io.Serializable. Is there any specific reason ?
        • 1. Re: why javax.servlet.http.HttpServlet is serializable ?
          900885
          Quoting a reply from the link below:

          >
          Technically, I believe the servlet container is allowed to "passivate" the servlet object to disk, in a similar way that EJB session beans can be. So you're correct to ask the question if your app will fail due to non-serializable fields.

          In practise, I've never heard of a container doing this, so it's really just legacy baggage from the bad old days of early J2EE. I wouldn't worry about it.
          >


          [http://stackoverflow.com/questions/179743/why-does-httpservlet-implement-serializable]