Difference b/w and

前端 未结 2 543
庸人自扰
庸人自扰 2020-12-14 16:21

DD elements and both can be retrieved by the getInitParameter() method, in the servlet code.<

2条回答
  •  难免孤独
    2020-12-14 17:02

    Servlet init parameters are for a single servlet only. Nothing outside that servlet can access that. It is declared inside the tag of Deployment Descriptor, on the other hand context init parameter is for the entire web application. Any servlet or JSP in that web application can access context init parameter. Context parameters are declared in a tag directly inside the tag.

    The methods for accessing context init parameter is

    getServletContext().getInitParameter("name"); 
    

    whereas the method for accessing servlet init parameter is

    getServletConfig().getInitParameter("name");
    

提交回复
热议问题