Can we write a constructor for a Servlet class ? if yes how ?
if no why not ?
Answer Posted / tharun raj
yes, we can provide a constructor in servlet calss..
Webcontainer uses the similar code shown below for creating
servlet object for our servlet class
Class c=Class.forName("OurServlet");
Object o=c.newInstance();
this newInstance() method uses zero argument constructor
while creating object..
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
Explain url encoding?
What is servlet collaboration?
What are the types of servlets? Explain
What is the directory structure of web application?
What is the life cycle of a servlet?
Tell us something about servletconfig interface.
What do you mean by singlethreadmodel interface?
How is the get () method different from the post() method?
Difference between doget and dopost?
How can you create a session in servlet?
What are the exceptions thrown by servlets? Why?
What is servlet lazy loading?
What is servlet? Explain
What do you mean by the servlet chaining?
Explain servlet events?