init-parameters

How to retrieve <servlet><init-param> value from web.xml in Servlet?

房东的猫 提交于 2019-12-18 07:02:28
问题 I need to retrieve init-param value from xml to Servlet i used following code <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>LoginServlet</servlet-class> <init-param> <param-name>jdbcDriver</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </init-param> </servlet> servlet code public void init(ServletConfig config) throws ServletException { super.init(config); System.out.println(config.getInitParameter("jdbcDriver")); } But It displayed null .. could any one

How to retrieve <servlet><init-param> value from web.xml in Servlet?

时间秒杀一切 提交于 2019-12-18 07:01:02
问题 I need to retrieve init-param value from xml to Servlet i used following code <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>LoginServlet</servlet-class> <init-param> <param-name>jdbcDriver</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </init-param> </servlet> servlet code public void init(ServletConfig config) throws ServletException { super.init(config); System.out.println(config.getInitParameter("jdbcDriver")); } But It displayed null .. could any one

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

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'

末鹿安然 提交于 2019-11-27 13:02:16
This is my web.xml xsd <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> Here is servlet node <servlet> <servlet-name>spring1</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> <init-param> <!-- here is a problem --> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml

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)

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'

你。 提交于 2019-11-26 16:11:38
问题 This is my web.xml xsd <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> Here is servlet node <servlet> <servlet-name>spring1</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> <init-param> <!-- here