Link to home
Start Free TrialLog in
Avatar of getravi2k
getravi2k

asked on

How to POST an audio to a servlet?

Hi,

I have a requirement.
In the current set up in production. There is a Tomcat server running.
When you call to a particular number it starts an IVR and it routes the call to bevocal and from there it is posted to our Production Tomcat server running.

In order to minimise the call everry time. what i am planning to deploy the whole production application locally on my m/c and i need to post a audio file to my tomcat servlet.

Plz let me know on how i can achieve it.

Regs,
Ravindra N
Avatar of getravi2k
getravi2k

ASKER

hi All,

I have solved the problem with this code.

URI doc_url  = new URI("http://localhost:8080/audioxml/XXX_submitRequest.jsp");

                  URI form_uri = new URI(doc_url, "");
                HTTPConnection con = new HTTPConnection(form_uri);

                // create the NVPair's for the form data to be submitted and do the
                // encoding
                NVPair[] files = { new NVPair("upload_file", "C:\\xxx_recordings\\record-2e18f03a.wav") };
                NVPair[] opts  = { new NVPair("secret", "data") };
                NVPair[] hdrs  = new NVPair[1];
                byte[] form_data = Codecs.mpFormDataEncode(opts, files, hdrs);

                // POST the form data, as indicated by the method attribute
                HTTPResponse rsp = con.Post(form_uri.getPathAndQuery(), form_data, hdrs);
ASKER CERTIFIED SOLUTION
Avatar of EE_AutoDeleter
EE_AutoDeleter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial