Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why HttpServlet also implements Serializable?

 
Kousik Majumder
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

As we know that if any of the super class implements an interface then the descending classes need not use to implement the interface.

So why HttpServlet implements Serializable interface where as it extends GenericServlet and GenericServlet implements Serializable ?




Thanks,

Kousik
SCJP 5
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably just clarity. It makes no difference to remove it, but this way they're saying "please note that this class really is serializable".
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By making the servlet serializable, the builders of the servlet API insure that the implementers have the option of serializing the servlet for persistence or load balancing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic