Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in web.xml

 
Bk Jacky
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i am just modifing web.xml file by adding this information

<context-param>
<param-name>breed</param-name>
<param-value>breed</param-value>
</context-param>

<listener>
<listener-class>classes.com.MyServletContextListener</listener-class>
</listener>

when i try to validate the web.xml file then it give following error

Parse Error at line 40 column 11: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,

listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,

taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".

Every thing is right why it is giving error like this? When i remove these lines then there is no error occurs.

what is going on tell me?

whole web.xml file. i commented out above information.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp_ID">
<display-name>test</display-name>
<servlet>
<servlet-name>MyServlet</servlet-name>
<display-name>MyServlet</display-name>
<description></description>
<servlet-class>classes.com.MyServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ListenerTester</servlet-name>
<display-name>ListenerTester</display-name>
<description></description>
<servlet-class>classes.com.ListenerTester</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>ListenerTester</servlet-name>
<url-pattern>/ListenerTester</url-pattern>
</servlet-mapping>
<!--

<context-param>
<param-name>breed</param-name>
<param-value>breed</param-value>
</context-param>

<listener>
<listener-class>classes.com.MyServletContextListener</listener-class>
</listener>
-->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

</web-app>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using version 2.3 of the specification, where the order of elements is important. I think you should move the context-param and listener tags before the servlets.
 
Bk Jacky
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Satou kurinosuke.Now every thing is working fine.Thanks a lot.

Bhupinder Singh
SCJP1.4
Preparing SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic