Can we define constructor in Servlet class?
Answer Posted / srikanth b
Yes, we can define constructor in Servlet class.
Constructor may be a Default Constructor or Parameterised
Constructor.
If we didn't write any constructor then the default
constructor will be executed. Because, to read init
parameters of a servlet we need servlet config object in the
life cycle of the servlet. Servlet config object object is
created after the execution of the constructor.
Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
What is pure servlet?
What is the difference between Servlets and Applets?
Why do we have servlet wrapper classes?
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!
What is http servlet?
Explain the difference between servlet and cgi?
What are the kinds of http requests?
How do you configure a centralized error handler in servlets?
How do I use cookies to store session state on the client?
Write a servlet to upload file on server.
How to notify an object in session when session is invalidated or timed-out?
How do servlets work?
What are advantages of servlets over cgi?
Difference between GET and POST?
What do you mean by request dispatcher in servlet? Also explain its methods.