0

i just want to add tag in my deployment descriptor. when i add this , it produces some error of following type: cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. Why this error is occurring and what is the solution of this error.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Servlet</display-name>
  <servlet>
    <servlet-name>Servlet1</servlet-name>
    <servlet-class>formdata.LoginForward</servlet-class>
  </servlet>
   <servlet>
    <servlet-name>Servlet2</servlet-name>
    <servlet-class>formdata.Welcome</servlet-class>
  </servlet>
<init-param> 
  <param-name>driver</param-name>  
<param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>  
  </init-param>

  <servlet-mapping>
    <servlet-name>Servlet1</servlet-name>
    <url-pattern>/myloginpage</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>Servlet2</servlet-name>
    <url-pattern>/welcomeuser</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>login.html</welcome-file>
  </welcome-file-list>
</web-app>
Vinit Saxena
  • 683
  • 2
  • 11
  • 27

1 Answers1

3

There are two types of param tags that can configured in the xml.

  • context-param

    directly inside the <web-app> tag that is applicable for the entire web application.

  • init-param

    applicable for a single servlet or filter only and must be enclosed inside the <servlet> or <filter> tag.

Read more...

Directly from web-app_2_3.dtd

<!ELEMENT filter (icon?, filter-name, display-name?, description?,filter-class, init-param*)>

<!ELEMENT servlet (icon?, servlet-name, display-name?, description?,(servlet-class|jsp-file), init-param*, load-on-startup?, run-as?, security-role-ref*)>
Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76