Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-10-2003, 03:01 AM   #1
Registered User
Join Date: Apr 2003
Posts: 3
Default how to use xml.sendandload with Java Servlet

Hello, guys, any one knows how to use XML.sendandload with a Java servlet.
Say, I have following code in my flash movie:

"sendXml = new XML("<p>Dog</P>");//create the send xml object
eventXml=new XML();
eventXml.ignoreWhite = true;//take care of white space, which may interfere with
//your reading of the xml otherwise
eventXml.onLoad = function(cool)//here,no matter what variable name you will use
//the variable is always set to a boolean value
//this toString() gives you the contents of the xml file in string format
eventItem = this.firstChild.childNodes;//our xml file is pretty simple
//with only one child,but this child has three children
//processing xml
//......blah blah blah

}//end of if(cool)
}//end of onload function

//the call to load method is always put at this postion, after we define
//the onload method

sendXml.sendAndLoad("http://degas.ecom.arizona.edu:5081/JiaoYu/servlet/Hello6",eventXml);//name of our xml file, in the same folder as this fla "

If I want to parse the xml part sent to the servlet, i.e. "<p>dog</p>", how can I do it in the servlet?
Thanks so much.
jyu is offline   Reply With Quote
Old 05-17-2003, 07:08 AM   #2
Registered User
Join Date: Apr 2003
Posts: 3

Finally, I got the answer to my own quesiton.

The key is at the Java servlet, and it is so simple after you know it.

Just do this in the Servlet:
import java.io.*;

BufferedReader br=req.getReader();
String reqBody=br.readLine();

Then parse the xml from string using any java xml parser.

A free one is available at www.jdom.orgHello, the problem is fixed finally
jyu is offline   Reply With Quote
Old 06-12-2003, 05:34 AM   #3
Registered User
Join Date: Apr 2003
Posts: 3

Another thing you may want to pay attention to is to use doPost method in the servlet instead of the doGet, this is almost always true with servlet working with FLash
jyu is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:35 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.