April 2018
Intermediate to advanced
382 pages
10h 11m
English
Sometimes you need to define some parameters for your servlet that goes beyond local variables – initParams is the place to do it:
@WebServlet(name = "InitConfigServlet", urlPatterns = {"/InitConfigServlet"}, initParams = { @WebInitParam(name = "key1", value = "value1"), @WebInitParam(name = "key2", value = "value2"), @WebInitParam(name = "key3", value = "value3"), @WebInitParam(name = "key4", value = "value4"), @WebInitParam(name = "key5", value = "value5") })
The @WebInitParam annotation will handle them for you and those parameters will be available for the server through the ServletConfig object.
Read now
Unlock full access