It's not better approach set as dataSource in webserver.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
posted 4 years ago
Struts Action objects are part of a Struts-based Controller. Ideally, you should not want to connect or access a data source from the Controller, i.e. Action objects.
As a treat, below is how to get the ServletContext object