title: SAX Parser: Specify DTD location in applet
body: <p>I have an applet that works fine in the applet viewer but once deplayed to the server it can't parse the XML files</p>
  
  <p>the reason is simple: the SAX parser is trying to open the dtd on the hard disk and not in the JAR.</p>
  
  <p>I was told to do this: </p>
  
  <blockquote>
    <p>URLs to resources can easily be formed
    using the URL(baseURL, pathString)
    constructor where the base URL is
    obtained from Applet.getDocumentBase()
    or Applet.getCodeBase().</p>
  </blockquote>
  
  <p>but I don't know how to apply this in my case:</p>
  
  <p>heres a XML sample :</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE note SYSTEM "leveldtd.dtd"&gt;   
  &lt;level&gt;
  ...
  &lt;/level&gt;
  </code></pre>
  
  <p>and here is the init of my parser</p>
  
  <pre><code>public static void parseThis(InputSource is) throws Exception{
          SAXParserFactory spf = SAXParserFactory.newInstance();
          SAXParser sp = spf.newSAXParser();
          XMLHandlerLevel myExampleHandler = new XMLHandlerLevel();
          XMLReader xr = sp.getXMLReader();
          xr.setContentHandler(myExampleHandler);
          /* Begin parsing */ 
          xr.parse(is);
      }
  </code></pre>
  
  <p>any ideas ? </p>
  
  <p>Jason</p>