deployment-descriptor

Difference b/w <context-param> and <init-param>

本小妞迷上赌 提交于 2019-11-27 13:34:56
问题 DD elements <context-param> and <init-param> both can be retrieved by the getInitParameter() method, in the servlet code. Now the question is, how does it differentiate <context-param> and <init-param> ? 回答1: Servlet init parameters are for a single servlet only. Nothing outside that servlet can access that. It is declared inside the <servlet> 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

Getting the init parameters in a servlet

心已入冬 提交于 2019-11-27 11:35:33
I am new to servlets. I got the init parameters in DD within the init() method using getInitParameter ("name"). I tried a lot from within doGet() method to access the init parameters, but it always returns null . I tried with getServletContext().getInitParametr("name") and with getServletConfig().getInitParametr("name") but they all return null . Can I get the init parameters in the doGet() ? The answer is - Yes, you can . OK, besides the JB Nizet's comment here are a few suggestions. 1) Have you added your init parameters while the Web Container / Application Server was running? Quote from "

Getting the init parameters in a servlet

陌路散爱 提交于 2019-11-27 04:02:49
问题 I am new to servlets. I got the init parameters in DD within the init() method using getInitParameter ("name"). I tried a lot from within doGet() method to access the init parameters, but it always returns null . I tried with getServletContext().getInitParametr("name") and with getServletConfig().getInitParametr("name") but they all return null . Can I get the init parameters in the doGet() ? 回答1: The answer is - Yes, you can . OK, besides the JB Nizet's comment here are a few suggestions. 1)