It is not recommended to override the init() method of the servlet.
Here is an example to override init() method of servlet:
public class BookDBServlet ... {
private BookstoreDB books;
public void init(ServletConfig config) throws ServletException {
// Store the ServletConfig object and log the initialization
super.init(config);
// Load the database to prepare for requests
books = new BookstoreDB();
}
...
}
you must write super.init(config) code and after that program specific logic.
Leave a Reply