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
What methodology can be followed to store more number of objects in a remote server?
How is an application exception handling is done using a servlet?
What is the process to implement doget and dopost methods?
What is http servlet?
How is the get () method different from the post() method?
What is cookies in servlet with example?
What do you mean by deployment descriptor?
What do you mean by servlet context?
How can we refresh automatically when new data has entered the database?
What is difference between GenericServlet and HttpServlet?
What is the difference between using getSession(true) and getSession(false) methods?
Explains the differences between context.getrequestdispatcher() and request.getrequestdispatcher()?
How do we call one servlet from another servlet?
Why don't we write a constructor in a servlet?
Explain in brief the directory structure of a web application?