Example to Override the init() method of the servlet

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

        // Load the database to prepare for requests
        books = new BookstoreDB();

you must write super.init(config) code and after that program specific logic.


About Sanju
I am Software Programmer. I am working in JAVA/J2EE Technologies.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: