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

Problem with DTD in web.xml

 
aliasger talib
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try post your 'web.xml' file...
Rene
 
aliasger talib
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic