Why java Soft has declared HttpServlet Class as an Abstract class?Is there any performance issue?

In HttpServlet class there is no any abstract method although javasoft declared this class as an abstract
class.Ok,this is valid in java.So if we want to utilize this class we will have to extends this class.But we can use to achieve this one by using Httpservlet class as simple java class also.

Questions by nabi_alam   answers by nabi_alam

Showing Answers 1 - 9 of 9 Answers

n

  • Apr 22nd, 2012
 

Security Purpose

  Was this answer useful?  Yes

Ganesh Bhat

  • Apr 2nd, 2015
 

The interface of HttpServlet is complete, but not the implementation/functionality of it. abstract restricts a developer to use the HttpServlet as is, rather it forces the developer to extend it and provide their implementation for doGet and doPost,

what happens if developer does not provide doGet implementation?

The doGet method returns an error code to the caller that given method ( get or post ) is not supported.

Hence, though interface is complete, functionality is incomplete, hence it s a smart way of indicating that you must extend the class and use it.

There seem to be no security or scalability reason behind this decision.
Ref: http://grepcode.com/file/repo1.maven.org/maven2/javax.servlet/servlet-api/2.5/javax/servlet/http/HttpServlet.java#HttpServlet.doGet%28javax.servlet.http.HttpServletRequest%2Cjavax.servlet.http.HttpServletResponse%29

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions