944,001 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 15531
  • Java RSS
Jul 24th, 2005
0

saving xml file from servlet request instance

Expand Post »
Hello,

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):
Java Syntax (Toggle Plain Text)
  1. my_xml = new XML("<tag1><tag2 /></tag1>");
  2. my_xml.contentType = "text/xml";
  3. my_xml.send("saveXML.jsp");

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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pete_R is offline Offline
2 posts
since Jul 2005
Jul 25th, 2005
0

Re: saving xml file from servlet request instance

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jul 25th, 2005
0

Re: saving xml file from servlet request instance

...(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:
Quote ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pete_R is offline Offline
2 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Logical Operator help
Next Thread in Java Forum Timeline: about CVS protocol and CVS client





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC