HttpServlet is declared abstract

HttpServlet is declared abstract

Explain why HttpServlet is declared abstract ?

View Answers

November 2, 2010 at 3:14 PM

The Constructor HttpServlet() does nothing because this is an abstract class. Default implementations in a few Java classes like HttpServlet don?t really do anything. Hence, they need to be overridden.

Usually one of the following methods of HttpServlet must be overridden by a subclass:

  • doGet, if the servlet supports HTTP GET requests
  • doPost, HTTP POST requests
  • doPut, HTTP PUT requests
  • doDelete, HTTP DELETE requests
  • init and destroy, to manage resources
  • getServletInfo, to provide information

May 6, 2013 at 7:44 PM

Hi, 1)Suppose HttpServlet Class isn't declared as abstract,Still there is no use of creating the object of HttpServlet class because all the method present inside the HttpServlet mostly does nothing. 2)Declaring HttpServlet as abstract,provides a signal to the Developer that the class has no practical use, and don't create the object of this class. rather have your own implementation for your service. 3)you can override any method from doxxx or service() method for your Servlet,and you can have own business logic.not necessary to override all the methods of HttpServlet. any corrections are welcomed,let me know if i am wrong anywhere. Thanks Balu









Related Tutorials/Questions & Answers:
HttpServlet is declared abstract
HttpServlet is declared abstract  Explain why HttpServlet is declared abstract
variables and methods declared in abstract class is abstract or not
variables and methods declared in abstract class is abstract or not  variables and methods declared in abstract class is abstract
Advertisements
Can a abstract class be declared final?
Can a abstract class be declared final?   Hi, Can a abstract class be declared final? Thanks
Java Abstract Class
Java Abstract Class       An abstract class is a class that is declared by using the abstract keyword. It may or may not have abstract methods. Abstract classes cannot be instantiated
Java httpservlet
Java httpservlet       HttpServlet class is an abstract class defined in "javax.servlet.http"...-independent servlet but HttpServlet class provides an HTTP protocol specific
Difference between GenericServlet and HttpServlet
and HttpServlet. GenericServlet is an abstract class that extends java.lang.Object while HttpServlet is an abstract class that extends GenericServlet... abstract service() to be overridden. A subclass of HttpServlet must override
Abstract Class in Java
Abstract class in Java is a class that is declared using abstract keyword.... An abstract method is declared without body but is followed by a semicolon.ADS... be declared as:ADS_TO_REPLACE_3 abstract class AbstractClass { } How to use
Methods of HttpServlet
Methods of HttpServlet  What are methods of HttpServlet
HttpServlet protocols
HttpServlet protocols   What are the type of protocols supported by HttpServlet?   It extends the GenericServlet base class and provides an framework for handling the HTTP protocol. So, HttpServlet only supports HTTP
abstract class
abstract class   Explain the concept of abstract class and it?s use with a sample program.   Java Abstract Class An abstract class is a class that is declared by using the abstract keyword. It may or may not have
Related to GenericServlet and HttpServlet
Related to GenericServlet and HttpServlet  Que: Http Servlet extends Generic Servlet then Why both GenericServlet and HttpServlet implements Serializable interface ?   GenericServlet and HttpServlet implement
Abstract and Interface
declared in a Java interface is by default final. An abstract class may contain non...Abstract and Interface  What is interface? When time is most suitable for using interface? Why we use interface instead of abstract? What
abstract method
abstract method  Can we have abstract class with no abstract methods
abstract class
abstract class  Can there be an abstract class with no abstract methods
Abstract class
Abstract class  Can an abstract class be final
Abstract class
Abstract class  what is an Abstract class
abstract method
abstract method  is final method is in abstract class
abstract method
abstract method  Can a concrete class have an abstract method
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
Can a class be declared as static?
Can a class be declared as static?  Hi, Can a class be declared as static? thanks
ModuleNotFoundError: No module named 'declared'
ModuleNotFoundError: No module named 'declared'  Hi, My Python... 'declared' How to remove the ModuleNotFoundError: No module named 'declared... to install padas library. You can install declared python with following
ModuleNotFoundError: No module named 'declared'
ModuleNotFoundError: No module named 'declared'  Hi, My Python... 'declared' How to remove the ModuleNotFoundError: No module named 'declared... to install padas library. You can install declared python with following
Can a class be declared as protected?
Can a class be declared as protected?  Hi, Can a class be declared as protected? thanks   Hi, A class can't be declared as protected. only methods can be declared as protected. http://www.roseindia.net/java
Interface and Abstract class
Interface and Abstract class  Difference between Interface and Abstract class? Give some example   Difference Between Interface and Abstract Class 1)Main difference is methods of a Java interface are implicitly
Abstract class
Abstract class  j   An Abstract class is a base class which... with an abstract keyword. For more information, visit the following links: http://www.roseindia.net/help/java/a/java-abstract-class.shtml http://www.roseindia.net/java
Java Abstract Class Example
if the subclass doesn't do so then it must have also declared as abstract... be declared as follows : public abstract class AbstractClassDemo { // declare...Java Abstract Class Example In this section we will read about the Abstract
abstract class
abstract class  abstract class AbstractClass{ } is possible and compile the class or any compile time error occur tell me the answer Blockquote
abstract class
abstract class  what is abstract class .why we use it or what is the need of this class?   Abstract class is like base class which contains abstract method and cannot instantiated.   Please go through
The abstract Keyword : Java Glossary
on classes and methods.  In case of class declared with an abstract keyword... name); If a class is declared abstract type then its methods will be also declared abstract type. When a method is declared abstract, the method can
Abstract class
Abstract class  Calendar cal=Calendar.getInstance() We know that Calendar is an abstract class so it can't be instantiated. So how we can say that cal is an instance of Calendar??? Beginner Question I suppose. Thanks in advace
Abstract class and abstract method
Some key points about abstract methods are as following An abstract modifier identifies abstract classes and methods An abstract methods cannot be private because it defined in the other class. An abstract methods cannot
code for abstract class
code for abstract class  code for abstract class
Version of com.englishtown>vertx-mod-httpservlet dependency
List of Version of com.englishtown>vertx-mod-httpservlet dependency
HttpServlet reading XML from HttpRequest - XML
HttpServlet reading XML from HttpRequest   Hi , My requirement is 1.Input to the HttpServlet will be the XML sent by upstream as HttpRequest.... HttpServlet should only read the XML from HttpRequest and put it to a string. Can any
Abstract class,Abstract methods and classes
Abstract methods and classes     ... so many times the word abstract. In java programming language the word abstract is used with methods and classes.  Abstract MethodADS_TO_REPLACE_1
abstract class and interface - Java Beginners
or more abstract methods. An abstract method is a method that is declared...abstract class and interface  what is the need for an abstract class? when should we use an abstract class? when should we use interface instead
What if the main() method is declared as private?
What if the main() method is declared as private?  Hi, What if the main() method is declared as private? Thanks   Hi, I have found some reference site for java programming coding for Main() method is declared
What is an abstract class?
What is an abstract class?  What is an abstract class
Java abstract class
Java abstract class  Can an abstract class be final
what is the meaning of abstract?
what is the meaning of abstract?  what is the meaning of abstract
What is an abstract method?
What is an abstract method?   Hi, What is an abstract method? thanks
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
Can a main method be declared final?
Can a main method be declared final?   Hi, Can a main method be declared final? Thanks   Hi, Yes we can. The final method can... be override in a subclass. for more about main method be declared final in Java
Why is the main method declared static?
Why is the main method declared static?  Hi, Why is the main method declared static? thanks   Hi, When we declare main() method in any... without creating any instance for the java class, where we declared it. Any static
Maven Dependency vertx-mod-httpservlet >> 0.1.0
You should include the dependency code given in this page to add Maven Dependency of com.englishtown >> vertx-mod-httpservlet version0.1.0 in your project
Abstract programs - Java Beginners
Abstract programs  give me the Abstract Methods programms and defind the Abstract Method and Abstract Class  Hi friend, This code will help you. abstract class A{ public abstract abs_value
abstract method in php - PHP
abstract method in php  How do i implement the abstract method in php? Which is the best way
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks

Ads