Can we write a constructor for a Servlet class ? if yes how ?
if no why not ?

Answer Posted / abhishek taneja

yes offcourse you can write a constructor for a servlet
after all it is a java class. you can simply provide but if
u do not provide then it is by default include the no
argument constructor that is used by the Init() method in
the servlet life cycle.

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the importance of init() method in Servlet ?

826


Why servlet is faster than jsp?

777


What are the disadvantages of storing session state in cookies?

903


How we can call a jsp from the servlet?

733


How can we achieve transport layer security for our web application?

796


What are the different methods of session management in servlets?

752


What's the servlet interface?

831


If servlet receives multiple requests, how many objects will it create?

1094


What is the use of attribute in servlets?

780


When to use doget() and when dopost()?

835


Why is Servlet so popular?

792


How do you run a servlet?

788


What is httpservlet and how it is different from genericservlet?

823


What is the difference between genericservlet and httpservlet

786


Why session tracking is needed?

795