saving xml file from servlet request instance

Reply

Join Date: Jul 2005
Posts: 2
Reputation: Pete_R is an unknown quantity at this point 
Solved Threads: 0
Pete_R Pete_R is offline Offline
Newbie Poster

saving xml file from servlet request instance

 
0
  #1
Jul 24th, 2005
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):
  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
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: saving xml file from servlet request instance

 
0
  #2
Jul 25th, 2005
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 2
Reputation: Pete_R is an unknown quantity at this point 
Solved Threads: 0
Pete_R Pete_R is offline Offline
Newbie Poster

Re: saving xml file from servlet request instance

 
0
  #3
Jul 25th, 2005
...(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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC