Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listener on URL

 
George Carlson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok guys and gals, please be nice to me. This may seem like a newb question and it probably is, but here is my situation.

I need to write a servlet (or web service or whatever I need to write) that listens for xml code that will be streamed to it and then parses the xml and processes it.

In other words, the servlet (or jsp) just sits there and waits for an incoming request. Another server will call this jsp or servlet and pass it an xml stream. I'll input the stream and process it.

I know how to parse and process the xml. i just need to get started on writing the file that will listen and stream in the xml.

Hopefully this makes sense and somebody may be willing to help me out.

Thanks for the help
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if I am getting the requirement right. Are you trying to log or write processed XML to files on the server?
 
Niranjan Aithal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about controller servlet ?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18154
52
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All servlets listen. They're not continuously-executing processes, nor are they callable subroutines. They're modules that process requests routed to them by the webapp dispatcher.

In the case of processing an XML upload, you'd typically embed the XML in an HTTP POST request. You would then put the parsing/processing code in the servlet's doPost() method. The raw data stream is accessible via the request.getInputStream() method, although if you use a form with a file upload button, the data will instead usually be spooled to a temporary location that you would access.
 
George Carlson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:All servlets listen. They're not continuously-executing processes, nor are they callable subroutines. They're modules that process requests routed to them by the webapp dispatcher.

In the case of processing an XML upload, you'd typically embed the XML in an HTTP POST request. You would then put the parsing/processing code in the servlet's doPost() method. The raw data stream is accessible via the request.getInputStream() method, although if you use a form with a file upload button, the data will instead usually be spooled to a temporary location that you would access.


Thanks. So, I don't need to do anything different if the servers are posting a stream from another server (possibly in another state or country). I've done a lot of servlet work, but I always call it from my local server.

Thanks again.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right. When your servlet processes a request, it doesn't know or care where the request comes from or how it was produced or what was in the mind of the person who caused it to be produced.
 
George Carlson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:That's right. When your servlet processes a request, it doesn't know or care where the request comes from or how it was produced or what was in the mind of the person who caused it to be produced.


Great. Thanks for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic