I am fixing a bug on an existing code concerning DocumentBuilder.parse. I have the below code:
 String theOutput;
    theOutput = response.encodeURL(prefix + "/include/sampleForConversion.jsp?" + request.getQueryString();
    StreamSource xmlSource = new StreamSource(new URL(theOutput).openStream(), "http://sampleApps.net/static/dataDef1.1.dtd");                                         
    Document xmlDoc = dBuilder.parse(xmlSource.getInputStream());
I dont understand why i am getting a null value for xmlDoc though I have valid values for theOutput and xmlSource variables. Please help.
thanks!
(xmlDoc == null) = trueor do you get an empty document ([#document: null])? The parse method should either return a document or throw an exception but never returnnull...[#document: null]does not mean a null document, that's justDocument's badly-writtentoString()output.SAXExceptionif any parse exception occurs;IOExceptionif any I/O error occurs; andIllegalArgumentExceptionif the input isnull. Even if that did not exhaust all the error cases, it's conventional in the JDK for the@returnsdocumentation to mentionnullif it's a possible return value.