File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes problem in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in web.xml" Watch "problem in web.xml" New topic
Author

problem in web.xml

Bk Jacky
Ranch Hand

Joined: Jun 11, 2005
Posts: 74
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>


SCJP1.4<br />SCWCD1.5<br />"Nothing is impossible"
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Bk Jacky
Ranch Hand

Joined: Jun 11, 2005
Posts: 74
Thank you very much Satou kurinosuke.Now every thing is working fine.Thanks a lot.

Bhupinder Singh
SCJP1.4
Preparing SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in web.xml