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

Discussion in 'Java' started by Alexandr Molochnikov, Aug 28, 2003.

  1. 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
    Alexandr Molochnikov, Aug 28, 2003
    #1
    1. Advertising

  2. Alexandr Molochnikov wrote:

    > 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>


    --
    darren@ public key
    davison|uk.net www.davison.uk.net/key.jsp
    Darren Davison, Aug 28, 2003
    #2
    1. Advertising

  3. Thanks. I will give it a try tomorrow.

    Alex.

    "Darren Davison" <> wrote in message
    news:3f4d99d1$0$192$...
    > Alexandr Molochnikov wrote:
    >
    > > 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>
    >
    >
    > --
    > darren@ public key
    > davison|uk.net www.davison.uk.net/key.jsp
    Alex Molochnikov, Aug 28, 2003
    #3
  4. 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.


    "Darren Davison" <> wrote in message
    news:3f4d99d1$0$192$...
    > Alexandr Molochnikov wrote:
    >
    > > 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>
    >
    >
    > --
    > darren@ public key
    > davison|uk.net www.davison.uk.net/key.jsp
    Alexandr Molochnikov, Aug 28, 2003
    #4
  5. Alexandr Molochnikov

    Sudsy Guest

    Alexandr Molochnikov wrote:
    > 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.
    Sudsy, Aug 29, 2003
    #5
  6. 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.

    "Sudsy" <> wrote in message
    news:...
    > > <!DOCTYPE web-app PUBLIC "Gestalt Corporation//EN"

    > ^
    > --------------------+
    >
    > The type should be SYSTEM, not PUBLIC.
    >
    Alexandr Molochnikov, Aug 29, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    1,996
    Jack Jia
    Apr 4, 2004
  2. O.B.
    Replies:
    2
    Views:
    3,320
    Damian Brunold
    Feb 7, 2006
  3. Replies:
    1
    Views:
    898
    Soren Kuula
    Jan 27, 2006
  4. Replies:
    4
    Views:
    151
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,292
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page