Is possible to have a constructor for a servlet?
Answer
Yes, it is possible to have a constructor for a servlet. However, it
is not practiced usually. The operations with the constructor can be performed
as usual just that it cannot be called explicitly using the ‘new’ keyword. This
is implicitly handled by the servlet container. Thus, the container performs
initialization as well as constructor functions.
Is possible to have a constructor for a servlet?
Answer
-
The init() method creates and loads the servlet. However, the servlet instance
creation of is handled by the servlet container which internally calls the
constructor. The communication between the servlet and the servlet container is
done through ServletConfig.
-
ServletConfig is a servlet configuration object. It is used by a servlet
container to pass information to a servlet during initialization.
-
Servlet class cannot declare a constructor with ServletConfig object as a
argument and cannot access ServletConfig object.
|
More Servlets links
Answer - Yes, it is possible to have a constructor for a
servlet.......
Answer - Applets are applications designed to be
transmitted over the network......
Answer - In some organizations, the intranet is blocked
by a firewall to the internet..........
Answer - Both are interfaces in the package
javax.servlet...............
|
|