File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kasper Rasmussen
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20161
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually what we really need is a description of the problem. Read this: ItDoesntWorkIsUseless
 
Kasper Rasmussen
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20161
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20161
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic