What is ServletContext

ServletContextInterface defines methods that a servlet can use to communicate to the Container. ServletContext Parameters are specified for entire application and are available for all servlets. ServletContext is also calledapplication object. ServletContext is used to obtain information about environment on which a servlet is running. There is one instance object of the ServletContext interface associated … Read more

Explain About ServletConfig Interface

ServletConfig a ServletConfig object is used to obtain configuration data when it is loaded. There can be multiple ServletConfig objects in a single web application. This object defines how a servlet is to be configured is passed to a servlet in its init method. Most servlet containers provide a way to configure a servlet at … Read more

How to Start Servlet Automatically

If present, calls the servlet’s service() method at the specified times. <run-at> lets servlet writers execute periodic tasks without worrying about creating a new Thread. The value is a list of 24-hour times when the servlet should be automatically executed. To run the servlet every 6 hours, you could use: <servlet servlet-name=”test.HelloWorld”> <run-at>0:00, 6:00, 12:00, 18:00</run-at> </servlet> … Read more

Why there is no Constructor in Servlet

Every java class will have aleast one constructor and servlets are no exception to this. But while using servlets ,we never instantiate the servlet rather the container does it for us by using the newInstance() defined in the Class class;  which in turn uses the empty(Default) constructor to create a new instance of the servlet. … Read more

What is the Importance of the destroy() Method in Servlet

The destroy() method is called only once at the end of the life cycle of a servlet. This method gives your servlet a chance to close database connections, halt background threads, write cookie lists or hit counts to disk, and perform other such cleanup activities. After the destroy() method is called, the servlet object is … Read more