My first post, a little nervous I am. I am starting with learning Java on the server side in servlets. I use Flash on the client side. What I would like to do is the following:

client side: send xml file / receive xml file
server: accept xml file and save it / sent xml file when requested.

To achieve this I use the client code (Flash snippet):

my_xml = new XML("<tag1><tag2 /></tag1>");
my_xml.contentType = "text/xml";

How can I retrieve the xml file from the servlet request instance and save it. I will do the xml creation and evaluation on the client. So retrieving xml from the servlet request instance and saving the xml data is all I want to do for now(to little experience yet on java...but for now I need this save mechanism to work).

Problem is two ways: 1) retrieving xml data 2) saving data
On 1) I do not have a clue
On 2) maybe use construction with: String xml = xml_data_as_a_string; File f = new File("c\xmlData");FileWriter fw = new FileWriter(f);fw.write(xml);

Thanks for any help

1) see the servlet API. You're likely looking at retrieving a large stream of data as part of a post request.
2) think about using the built-in XML support of the Java core API, or else to use a 3rd party XML parser like Xerces.

...(I still will have to find out the exact programming code.... but this is about the approach)....

Ok let's see ...would the following then work? Basic idea....use buffered reader via:

BufferedReader bin = request.getReader()

This retrieves the body of the request as character data using a BufferedReader.
Since only the body and no header info is in the "bin" , only xml data is there. Now by retrieving each line via bin.readline() and saving it into a standard file by using a FileWriter I can save the xml data?

Is this corect thinking?? If so, is this an efficient way to do it(no better way maybe)

Thank you

This article has been dead for over six months. Start a new discussion instead.