Can we define constructors in Servlet?
Answer Posted / vivekanand prasad
The init() method creates and loads the servlet.But the servlet instance is first created through the constructor (done by Servlet container). We cannot write constructors of a servlet class with arguments in servlet (It will throw Exception). So, They provided a init() method that accepts an ServletConfig object as an argument.ServletConfig object supplies a servlet with information about its initialization (init) parameters.Servlet class cannot declare a constructor with ServletConfig object as a argument and cannot access ServletConfig object.
| Is This Answer Correct ? | 20 Yes | 3 No |
Post New Answer View All Answers
How would you create a button with rounded edges?
What value does read() return when it has reached the end of a file?
What is the difference between system.out ,system.err and system.in?
What is Stream Tokenizer?
Name three subclasses of the component class?
What modifiers may be used with an inner class that is a member of an outer class?
Is “abc” a primitive value?
Is the infobus client side only?
Is the ternary operator written x : y ? Z or x ? Y : z ?
What is the difference between the string and stringbuffer classes?
What is Remote Server?
What is metaspace?
which book is better for jdbc ,servlets and jsp
Name the eight primitive java types.
What are various types of class loaders used by jvm?