answersLogoWhite

0

Why servlet has no constructor?

Updated: 8/19/2019
User Avatar

Wiki User

13y ago

Best Answer

Because it is not a regular Java Class that is executed by a JVM. It is a special Java class that is executed by the Web Container which initializes and loads the servlet and the service methods get executed everytime it receives a request.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why servlet has no constructor?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you use constructor in servlet?

Yes you can but it is not required. A Servlet is nothing but another .java file and all rules that are applicable to standard Java classes are applicable to them. Note: Even if you write a constructor in a servlet, it will not get executed.


How do you create object of javabeen in servlet?

A JavaBean is nothing but a regular Java Class and hence it can be instantiated using the new keyword and invoking the bean constructor


What are types of servlet?

Http servlet and Generic servlet


What is java servlet chaining?

Servlet Chaining means the output of one servlet act as a input to another servlet. Servlet Aliasing allows us to invoke more than one servlet in sequence when the URL is opened with a common servlet alias. The output from first Servlet is sent as input to other Servlet and so on. The Output from the last Servlet is sent back to the browser. The entire process is called Servlet Chaining.


Default constructor in java?

If you don't type a constructor into your class code, a default constructor will be automatically generated by the compiler. The default constructor is ALWAYS a no-arg constructor. (Obviously the compiler has no clue what all arguments you might want for your class. So it takes the safe way out with a no argument constructor) A no-arg constructor is not necessarily the default (i.e., compiler-supplied) constructor, although the default constructor is always a no-arg constructor. The default constructor is the one the compiler provides! While the default constructor is always a no-arg constructor, you're free to put in your own no-arg constructor.


What is an empty constructor?

An empty constructor takes no arguments and calls the default constructor


What is the difference between implicit and explicit call of constructor in c plus plus?

An implicit constructor call will always call the default constructor, whereas explicit constructor calls allow to chose the best constructor and passing of arguments into the constructor.


When a object is passed to a function as argument why it is not generating an error if the parameterized constructor is defined and not the default constructor?

default constructor is used only when the programmer does not use a constructor to initialize objects. Once the programmer defines a constructor then the default constructor is no longer used


Can you call constructor?

yes we can call constructor


What is use of constructor in java?

Constructor is used to do something (written in constructor) immediately after object creation.


What is a default parameterized constructor?

There is no such thing as a default parameterized constructor. The default constructor is always the 'no-arg' constructor and does not take any parameters or arguments as input


What happens when no constructor function is declared in a class - in Java?

When any constructor is deffined in your class, the java compiler create a default no argument constructor for you. This constructor only have an invocation to the super class constructor (" super( ) ").