# Why HttpServlet classs is declared as abstract class BUT with 100 % concrete functionality ?

* It is abstract because the implementations of key servicing methods have to be provided by *(i.e., overridden by)* servlet developer. Since it's abstract, it's instance cannot be created.

### A subclass of HttpServlet must override at least one method, usually one of these:

* doGet, if the servlet supports HTTP GET requests.
* doPost, for HTTP POST requests.
* doPut, for HTTP PUT requests.
* doDelete, for HTTP DELETE requests.
* init and destroy, to manage resources that are held for the life of the servlet.

### What happens if you dont override the methods?

* If you extend the class without overriding any any of these methods as per your requirement, you will get a useless servlet; *(i.e. it will give an error response for all requests)*.*(**HTTP 405** : Method not implemented)*. So, **if the class was not** abstract, then any direct instance of HttpServlet would be **useless**.

### But why is it abstract?

* So the reason for making the HttpServlet class abstract is to prevent a programming error.
* As a servlet developer, you can choose to override the functionality of your requirement (eg : doPost) & ignore other methods.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://anon-coders-notes.gitbook.io/techwriterdev/languages/java/01_backend/02_j2ee_basics/regarding-httpservlet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
