File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes NEWBIE Q: How to parse an XML HTTP-POST request in servlets using JDOM? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "NEWBIE Q: How to parse an XML HTTP-POST request in servlets using JDOM?" Watch "NEWBIE Q: How to parse an XML HTTP-POST request in servlets using JDOM?" New topic
Author

NEWBIE Q: How to parse an XML HTTP-POST request in servlets using JDOM?

Kasper Rasmussen
Greenhorn

Joined: Sep 28, 2010
Posts: 4
I have a client that sends an XML to my server using a POST request. Now I want my server to be able access the XML document. I am using JDOM and this code in my servers doPost returns a HTTP response code 500, although I would have wanted it to parse the requested XML document.



Just in case you need it, I have included the code of the client, that sends the HTTP POST request:

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

Actually what we really need is a description of the problem. Read this: ItDoesntWorkIsUseless
Kasper Rasmussen
Greenhorn

Joined: Sep 28, 2010
Posts: 4
Paul Clapham wrote:Actually what we really need is a description of the problem. Read this: ItDoesntWorkIsUseless


Sry, post have been edited to help you help me :)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

I'm guessing that the part about HTTP response code 500 was inserted later?

Anyway response code 500 means that the server had an error. So that's all we know so far. Your task now is to find out what that error is. Normally the server would log these errors in a log file somewhere. When you find that file you will see an error message and a stack trace which tells you what went wrong.
Kasper Rasmussen
Greenhorn

Joined: Sep 28, 2010
Posts: 4
Ok think I have found the error message:



Seems that it cannot find my parser? I have only imported the jdom.jar, shouldn't that be enough?>.>

EDIT: I know that it says doGet in the error message although I use a doPost, but this was the only way I could find the error message - could not find it anywhere in my Tomcat server folder :/

EDIT2: Okay so the problem is that my server cannot find the jdom.jar because the library has to be located in the web-inf folder, but I cannot seem to get the jar-file copied to that location in eclipse =/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

Kasper Rasmussen wrote:Okay so the problem is that my server cannot find the jdom.jar because the library has to be located in the web-inf folder, but I cannot seem to get the jar-file copied to that location in eclipse =/

Yes, that's right, you've identified the problem. And as you see it isn't an XML problem at all. If you would like this post moved to the forum about Eclipse then just post a response here asking for that or send me a PM.
Kasper Rasmussen
Greenhorn

Joined: Sep 28, 2010
Posts: 4
No problem - I found a solution - just had to move the .jar to the Java EE Module Dependencies and now it works like a charm
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NEWBIE Q: How to parse an XML HTTP-POST request in servlets using JDOM?