In my project, I am using Servlet 3.0, and I tried using annotations.
To initialize the connection parameters for the database, I use this in my servlet:
@WebServlet(name = "FrontServlet", urlPatterns = {"/index"}, initParams = { @WebInitParam(name = "userDB", value = "root"), @WebInitParam(name = "passwordDB", value = "*****")})
Now that I have packaged the project in WAR, I do not have web.xml, so I cannot edit the init parameters, as I did with the older version of the servlet.
My question is, can I change the initialization parameters when the project is packaged in WAR? If so, how? Otherwise, what approach should be used to store init parameters and the possibility of modifying them in the WAR?
If possible, I would like to avoid re-creating the entire web.xml with all the URL patterns, etc.
EDIT:
Finally, I saved:
@WebServlet(name = "FrontServlet", urlPatterns = {"/index"})
And I load the DB parameters using Properties , accessing the configuration file using getClass().getClassLoader().getResourceAsStream("servlet/config/config.ini")
source share