Yes, Servlet can have Constructor, it's perfectly legal but it's not the right way to initialize your Servlet. You should use the init() method provided by the Servlet interface to initialize the Servlet. If you remember, Servlet's are special in a sense that they are instantiated by the container and managed by the container. A servlet container like Tomcat creates a pool of multiple Servlets to serve multiple clients at the same time. They instantiate Servlet by calling the default no-argument constructor and suppose you have declared another constructor which takes a parameter e.g. HelloServlet(String name) than Java compiler will not add the default no-argument constructor and Servlet container will not able to initialize the Servlet. That's why it's important not to provide a constructor in Servlet, but if you do, make sure you also add a default constructor there for Servlet container.
Read more »