File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Listener on URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Listener on URL" Watch "Listener on URL" New topic
Author

Listener on URL

George Carlson
Greenhorn

Joined: Aug 24, 2000
Posts: 15
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

Not sure if I am getting the requirement right. Are you trying to log or write processed XML to files on the server?

SCJP, SCWCD.
|Asking Good Questions|
Niranjan Aithal
Greenhorn

Joined: Mar 17, 2012
Posts: 6
Are you talking about controller servlet ?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16058
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
George Carlson
Greenhorn

Joined: Aug 24, 2000
Posts: 15
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Aug 24, 2000
Posts: 15
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Listener on URL