servlets

servlets

Even though HttpServlet doesn't contain any abstract method why it is declared as abstract class? what benifits we can get by declaring like this?(i.e, with out containing the abstract methods, declaring a class as abstract)

please give the answere

View Answers

April 15, 2011 at 12:36 PM

The servlet programmers typically don't want their servlet to support the main HTTP methods (POST, GET), so it would be annoying to make the doGet(), doPost(), etc. methods abstract, since programmers would be forced to implement methods that they don't need. Therefore, HttpServlet provides a default implementation for all those methods that does nothing except return an error statuscode to the client. Programmers can override the methods they need. But actually using the HttpServlet class itself make no sense, so it is called as abstract.









Related Tutorials/Questions & Answers:

Ads