Reputation: 948
The init
method in most (all) of my servlets is similar. Mostly initializing a DataSource
I am thinking of creating a BaseServlet
having a protected DataSource
and the init
method implemented and all other servlets extend this BaseServlet
.
Any Gotchas I should be wary of?
Upvotes: 1
Views: 1650
Reputation: 17923
In the current approach:
BaseServlet
will create its own datasource as the init()
method will be called multiple times. Assuming above is true, I would suggest following
Upvotes: 1
Reputation: 1905
If you just need initialize the Database related stuff, you can put that into ServletContext, I am not a fun of so many class inheritance.
nowadays, seems we don't just start from servlet, why not choose a framework?
Upvotes: 1