web.xml in servlet deployment - how to dummy out DOCTYPE

  • Thread starter Alexandr Molochnikov
  • Start date
A

Alexandr Molochnikov

Is there any way to deploy a servlet in Tomcat with web.xml file NOT having
DOCTYPE tag? If I do not specify it, the servlet starts, but Tomcat
generated the following error:

Aug 27, 2003 6:13:08 PM org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 10 column 10: Document root element "web-app",
must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "web-app", must match
DOCTYPE root "null".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
....

However, if I do specify DOCTYPE, it wants me to put in a valid URL to the
DTD file - which I do not have/need. So, I am looking for a way to set
DOCTYPE to a dummy file just to keep the parser happy... with no success so
far.

Can it be done? Or am I on a wrong track altogether, and a valid DTD must be
in place, whether I like it or not?

Thanks for any help.

Alex Molochnikov
Gestalt Corporation
 
D

Darren Davison

Alexandr said:
However, if I do specify DOCTYPE, it wants me to put in a valid URL to the
DTD file - which I do not have/need. So, I am looking for a way to set
DOCTYPE to a dummy file just to keep the parser happy... with no success
so far.

it doesn't have to be an external URL, you can place it in your WEB-INF
directory and reference it as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "/WEB-INF/web-app_2_3.dtd">

<web-app>
....
</web-app>


You can d/l the dtd file from Sun: <http://java.sun.com/dtd/web-app_2_3.dtd>
 
A

Alex Molochnikov

Thanks. I will give it a try tomorrow.

Alex.

Darren Davison said:
it doesn't have to be an external URL, you can place it in your WEB-INF
directory and reference it as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "/WEB-INF/web-app_2_3.dtd">

<web-app>
...
</web-app>


You can d/l the dtd file from Sun:
 
A

Alexandr Molochnikov

OK, I tried it... and the log says:

2003-08-28 10:44:03 ContextConfig[/StepForward] Parse error in application
web.xml
java.io.FileNotFoundException
at
org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContex
tURLConnection.java:344)
at java.net.URL.openStream(URL.java:960)
....

The file is located in:
C:\Tomcat4.1\webapps\StepForward\WEB-INF\web-app_2_3.dtd

and web.xml contains this entry:

<!DOCTYPE web-app PUBLIC "Gestalt Corporation//EN"
"/WEB-INF/web-app_2_3.dtd">

Any ideas?

Thanks,

Alex.
 
S

Sudsy

Alexandr said:
OK, I tried it... and the log says:

2003-08-28 10:44:03 ContextConfig[/StepForward] Parse error in application
web.xml
java.io.FileNotFoundException
at
org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContex
tURLConnection.java:344)
at java.net.URL.openStream(URL.java:960)
...

The file is located in:
C:\Tomcat4.1\webapps\StepForward\WEB-INF\web-app_2_3.dtd

and web.xml contains this entry:

<!DOCTYPE web-app PUBLIC "Gestalt Corporation//EN"
^
--------------------+

The type should be SYSTEM, not PUBLIC.
 
A

Alexandr Molochnikov

Thank you for looking into this. The solution was to not only use SYSTEM for
type, as you pointed out, but also to specify the file name without
preceding directory level:

<!DOCTYPE web-app SYSTEM "web-app_2_3.dtd">

I am a happy camper now!

Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top