Can I declare parameterized constructor inside servlet which is only constructor ?
If no then why ?
Can I declare parameterized constructor inside servlet which is only constructor ?
If no then why ?
Since servlets are instantiated by the container they need a no-argument constructor.
Additionally the container may reuse servlets and will not call the constructor on reuse.
You'll need to initialize the variables through <servlet-param>
or use a Framework like Spring which can allow you to Proxy the Servlet to a different class that acts just like any other bean.