This is a convenience implementation of the Servlet interface, which means that developers do not need to implement all service methods. If your servlet is required to handle doGet requests for example, there is no need to write a doPost method too.
The Constructor HttpServlet does nothing because this is an abstract class. Default implementations in a few Java classes like HttpServlet donot really do anything. Hence, they need to be overridden. Posted by satyamsoft on January 31, in Servlet. You are commenting using your WordPress. HttpServlet class is declared as abstract class why because sun people dont want to create an object to HttpServlet class for this reason it is declared as abstract.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Why HttpServlet class is declared as abstract? Asked 10 years, 3 months ago. Active 8 years, 6 months ago. Viewed 11k times.
BalusC 1. Because that's the way they designed it. Not constructive. Add a comment. Why GenericServlet is an abstract class? Interview Candidate Dec 12th, 13 First Prev Next Last. Showing Answers 1 - 13 of 13 Answers. Kethams Dec 14th, To prevent creating of objects.
Deepak Sharma Dec 19th, Rahul Gupta Dec 20th, Naresh Kumar Reddy Jan 8th, Naresh Kumar Reddy Mar 8th, Avijit Chowdhury Nov 10th, Is HttpServlet an abstract class or interface? Optional 'thank-you' note:. If yes,where are we implementing all methods of HttpServlet in our servlet?
As JAVA API says all methods in the abstract class or interfaces should be implemented in its subclass,otherwise that class will become abstrat.. If HttpServlet is abstract class or interface and we are not implementing all methods of it, my servlet should become abstract.. Why we are not following this in servlet? Veena Rani. HttpServlet class is an abstract class but it does nothave any abstract methods. But for proper functioning we normally override the doGet or doPost because these methods are called by the service method of the servlet depending upon the request received.
Sudd Ghosh. GenericServlet is an abstract class and its service method is abstract. So in case you extend this class, you need to provide an implementation of the service method.
0コメント