LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   DTD files (https://www.linuxquestions.org/questions/linux-newbie-8/dtd-files-685143/)

ptemmerman 11-21-2008 06:12 AM

DTD files
 
Hi All,

This isn't really a Linux related question, but I thought I'd ask it anyway, since this will be probably very basic for most people.

I just had a colleague coming up to me saying that there Tomcat application won't start because it has no internet connectivity.
The Tomcat server is unable to retrieve the dtd files from java.sun.com.

As far as I know, the DOCTYPE specifiers (example below) are only being used to identify which type of document the parser is working with, rather than for validation purposes.

Quote:

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
Thus it seems rather strange to me that Tomcat would be actually trying to fetch those dtd's from the internet.

However, if somebody could confirm this, then I can rest assured :)

Thanks

paulsm4 11-23-2008 01:45 PM

Hi -

You're correct - Tomcat is *not* trying to fetch stuff from Internet just because of the DOCTYPE definition. Your colleague is mistaken.

"http://java.sun.com/dtd/web-app_2_3.dtd" is a "URN" (Universal Resource Name). It's only purpose is to provide a unique namespace, *not* to actually fetch something from the Internet.

The details are in RFC 3151:

http://www.faqs.org/rfcs/rfc3151.html

ptemmerman 11-24-2008 01:24 AM

Thank you very much

ptemmerman 11-24-2008 09:41 AM

UPDATE:

It actually seems that it's only partially true.
The parser tries to validate the document using the doctype specification. The thing is that it first tries to look for the dtd in the jar using the DTD name. If this fails, then the dtd is fetched from the URL.

Quote:

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
In this case, it would first try to find //Sun Microsystems, Inc.//DTD Web Application 2.3// in some location (don't ask me where..maybe in JDK's jars or something). If this is not being found, then it tries to fetch from the URL.

I was able to reproduce this by altering the DTD name to something bogus, i.e. //SunZZZZ MicrosystemsZZZ, Inc.//DTD Web Application 2.3//
My packet sniffer showed me that the it connected to the sun website.

If anybody has a better understanding of this and would like to share it..feel free to do so.

salter 11-24-2008 10:49 AM

If the basic problem is about running a tomcat a tomcat application without worldwide connection, than the practical approach would be to copy the DTD to the local PC and modify/or to modify the DOCTYPE url.

This DOCTYPE behaviour is actually not specific to tomcat - it's the same behaviour as with all SGML-based marked-up contents (HTML, XML, etc): if a DOCTYPE needs to defined, then use one that can be accessed.

This problem doesn't show up for HTML documents, because all sane browsers will have a default DOCTYPE setting if the HTML doesn't provide one, and that default is either part of the browser code or it is installed along with it. So you never have this problem during offline browsing.

It seems that tomcat doesn't declare anything as default on it's own, but rather tries to access any DTD at the given url.


All times are GMT -5. The time now is 04:44 PM.