How to POST an audio to a servlet?


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.

Ravindra N
Who is Participating?
EE_AutoDeleterConnect With a Mentor Commented:
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

getravi2kAuthor Commented:
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);
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.