Despite the fact that API description says that @WebInitParam annotation can be used on Servlet and Filter classes to define init parameter this is not correct.
Servlet 3.0 Specification
@WebInitParam can be used only as parameter to @WebServlet and @WebFilter annotations:8.1.3 @WebInitParam
This annotation is used to specify any init parameters that must be passed to the
Servlet or the Filter. It is an attribute of the WebServlet and WebFilter
annotation.
Code: Select all
@WebServlet(urlPatterns="/AuthenticationServlet", initParams=@WebInitParam(name="test", value="testVal"))
public class AuthenticationServlet extends HttpServlet {}