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 is servlet chaining?
Can we refresh servlet in client and server side automatically?
Can servlet have a constructor ?
What is MIME Type?
Difference between forward() method and sendredirect() method ?
Difference between httpservlet and generic servlets?
What is load-on-startup in servlet?
How do you deal property files in servlet?
What is called Scriptlet?
What do you mean by servlet context?
Explain jsessionid and when is it created?
Hello, My project requirement is like I need to create a web page using MVC pattern. I hava a bean class, jsp page, servlet, service and dao. My jsp has two fields. One is dropdown list. The option values has to get populated from the database table. The other one is a text box and its value has to come from database table. As of now I have defined the fields in bean class, got the values from database using arraylists in dao class and I called this from service class. Can anyone please tell me the workflow of how the servlet will get this arraylist and populate the arraylist values as dropdown options in jsp page? Also I would like to know the role of bean class in MVC pattern? Thanks in advance!
Can we get PrintWriter and ServletOutputStream both in a servlet?
Which httpsession object is used to view and manipulate information about a session?
How do you define a servlet?