my dog learned polymorphism*
The moose likes Tomcat and the fly likes Problem with DTD in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Problem with DTD in web.xml" Watch "Problem with DTD in web.xml" New topic
Author

Problem with DTD in web.xml

aliasger talib
Ranch Hand

Joined: Aug 19, 2002
Posts: 37
Hi ...
I'm having an error with a web.xml file of my application. I can't pinpoint what exactly the error is, but I know it's in that file because I'm getting a zillion errors on starting Tomcat and the XML file doens't open in IE.
Here's the error when I'm opening it in IE:
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.

--------------------------------------------------------------------------------
External ID is invalid. Error processing resource 'file:///D:/Tomcat 4.1/webapps/chapter9/WEB-INF/web.xml'. Line 3, Position 19
<!DOCTYPE web-app xmlns="http://java.sun.com/xml/ns/j2ee"
------------------^

And this is the DTD of the file:
<!DOCTYPE web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">

I'd appreciate it if anyone got back to me on this. Thanks a lot.
- A.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Try post your 'web.xml' file...
Rene


Regards, Rene Larsen
Dropbox Invite
aliasger talib
Ranch Hand

Joined: Aug 19, 2002
Posts: 37
Rather long....
----------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">

<context-param>
<param-name>
productsFile
</param-name>
<param-value>
products.xml
</param-value>
</context-param>

<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>chapter8.MyServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>HeaderServlet</servlet-name>
<servlet-class>chapter8.HttpServletHeaders</servlet-class>
</servlet>

<servlet>
<servlet-name>HomeServlet</servlet-name>
<servlet-class>chapter8.MainServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>CheckOutServlet</servlet-name>
<servlet-class>chapter8.CheckOutServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>CartServlet</servlet-name>
<servlet-class>chapter8.CartServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HeaderServlet</servlet-name>
<url-pattern>/HeaderServlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HomeServlet</servlet-name>
<url-pattern>/home.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CheckOutServlet</servlet-name>
<url-pattern>/CheckOutServlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>CartServlet</servlet-name>
<url-pattern>/Cart</url-pattern>
</servlet-mapping>
<jsp-config>
<jsp-property-group>
<url-pattern>/main.jsp</url-pattern>
<include-prelude>/header.jsp</include-prelude>
<include-coda>/footer.jsp</include-coda>
</jsp-property-group>
</jsp-config>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<error-page>
<exception-type>
store.ItemAlreadyAddedException
</exception-type>
<location>
/duplicateItem.html
</location>
</error-page>
</web-app>
-----------------------------------
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You need to replace the ref. to the XML-schema with a ref. to the right DTD and add the start 'web-app' tag.

Rene
aliasger talib
Ranch Hand

Joined: Aug 19, 2002
Posts: 37
OK, but then what if I need to use the XML namespace as the DTD suggests I do?
And also, the version mentioned in the DTD was 2.4. I was running it with Tomcat 4.1.18. DO you think that's the problem? I think I'll need Tomcat 5.0 to support version 2.4. I tried with 5.0 but since it's the Alpha version, I'm getting a zillion errors.

Any help?
Thanks...
John S Green
Greenhorn

Joined: Mar 22, 2005
Posts: 7
The solution is: don't add '!DOCTYPE'.

It should just be:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">

or in full

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">

... etc ...

Good luck! I just worked this out the 'hard way' today!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with DTD in web.xml