Servlet 3 WebInitParam example - Declare Servlet 3.0 Initialization parameter using @WebInitParam

Declare Servlet 3.0 Initialization parameter using @WebInitParam

Posted on

Servlet 3 WebInitParam example - Declare Servlet 3.0 Initialization parameter using @WebInitParamServlet initialization parameters are used to course of the information when servlet initializing. Earlier than servlet 3, this knowledge have to placed on deployment descriptor and servlet will learn the information in init() methodology utilizing ServletConfig Object. For each servlet, the information is exclusive and never been shared in between of two servlets.

Earlier than Servlet Three Initialization parameter declared in net.xml as following

Servlet Three include @WebInitParam annotation, utilizing which developer can outline the initialization parameter in Servlet itself. Later servlet can entry that parameter by utilizing config.getInitParameter() methodology.

Following instance reveal using @WebInitParam annotation in Servlet 3.

The output will appear like much like following…

Servlet 3 WebInitParam - Declare Servlet 3.0 Initialization parameter using @WebInitParam

Servlet3 WebInitParam Example

Supply techzoo.org