servlet constructor

Can we have Servlet Constructor?

Yes, you can have as per rule. It is executed even before init(). Then why generally we avoid constructor in Servlets. First let us write one simple example and see it is true or not; then we will go into details. Example on Servlet Constructor

Output screenshot on Servlet…