Results 1 to 1 of 1
Thread: DocumentBuilder parse
- 10-20-2011, 05:12 PM #1
DocumentBuilder parse
Hello all...newbie here,
I am using the NetBeans IDE 7.0.1 to create a Java Web Application. I have a method that gets an XML document from a Url string argument and parses it into a DOM document. This all works perfectly in my NetBeans IDE environment. But when I deploy the application to my GoDaddy host, it does not function and I am in desparate help from someone kind enough to provide me only with direction on where to look. It has something to do with the DocumentBuilder parse method but I don't know how to interpret the failure.
What is returned from validateResponse() is "Parse Failure..."
If parse threw an exception, would I expect to get "Parse Failure...responseDOM is null." returned?
I don't have the knowledge to explain what I think happened. It is unclear to me how execution went from db.parse to the last finally instead of to the first finally.
When I capture the requestUrl and copy and paste it into my browser, I get a nicely formatted XML document in return so I don't believe there is any garbage in so to speak.
What is more confusing is that this all works perfectly in my development environment using NetBeans. When I deploy it to GoDaddy, the above failure is generated instead. There is obviously a difference between servers but I'm not knowledgeable enough to know where to look or what to do about it. Can anyone suggest a more appropriate forum or website? I appreciate any assistance that can be provided to this C++ programmer struggling with his first Java application.
~Greybeard
Java Code:private String validateResponse(String requestUrl) throws RuntimeException { String resReturn = "Parse Failure."; try { try { // Get the DOM Document DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); resReturn += "."; DocumentBuilder db = dbf.newDocumentBuilder(); resReturn += "."; try { try { responseDOM = db.parse(requestUrl); } catch (Exception e) { throw new RuntimeException(e); } } finally { if(responseDOM == null) { return resReturn + "responseDOM is null."; } else { resReturn = "The text content of the parsed DOM document is<br />" + responseDOM.getDocumentElement().getTextContent(); } } } catch (Exception e) { resReturn += "Exception in validateResponse" + e.getMessage(); } } finally { return resReturn; } }
Similar Threads
-
DocumentBuilder.parse() prints error but doesn't throw exception
By kjkrum in forum XMLReplies: 1Last Post: 05-31-2011, 11:02 PM -
How to parse this value
By Ajitha in forum New To JavaReplies: 2Last Post: 06-03-2010, 07:26 AM -
using parse
By mustachMan in forum New To JavaReplies: 2Last Post: 01-15-2010, 01:32 AM -
External entity in XML causing null pointer exception during DocumentBuilder.parse
By sri_kumar_4u in forum XMLReplies: 0Last Post: 12-04-2009, 12:39 PM -
SAX Parse
By bluefloyd8 in forum New To JavaReplies: 1Last Post: 01-25-2008, 03:57 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks