Hi Niti,

Do not you think the header should be set as follows?

Header header1 = *new* Header ("Accept","audio/x-wav");

postMethod.setRequestHeader(header1);
--Bahman

Ext:34334


On 1/31/07, Niti Bhatt (PL/EUS) <[EMAIL PROTECTED]> wrote:

Hi Community,
   I am trying to send audio data using PostMethod to a webserver (runs
on localhost:8080). But it seems, no data is received when I do
request.getInputStream() on the server side. On the server side I am
trying to fetch the data in a jsp page (GetRequest.jsp) which would read
the inputstream and store the data in a file. It would be very helpful
if someone can point at the problem...

Following is the code of the client:


HttpClient client = new HttpClient();
PostMethod postMethod = new
PostMethod("http://localhost:8080/js/GetRequest.jsp";);

File f = new File("test.wav");
AudioInputStream ais = AudioSystem.getAudioInputStream(f);
InputStreamRequestEntity re = new InputStreamRequestEntity(ais);
postMethod.setRequestEntity(re);
postMethod.setRequestHeader("Content-type", "audio/x-wav");
int statusCode1 = client.executeMethod(postMethod);
System.out.println("statusLine>>>" + postMethod.getStatusLine());
postMethod.releaseConnection();

On the server side, I am using the following

ServletInputStream fin = request.getInputStream();
FileOutputStream fout = new
FileOutputStream("c:"+System.getProperty("file.separator")+"ringtone.wav
");
byte[] buff = new byte[1024*16];
int r = fin.read(buff);
         while(r!=-1) {
         fout.write(buff, 0, r);
         r = fin.read(buff);
         }
System.out.println("Job is done");
fout.close();
fin.close();

Thanks for your help...

Niti

Reply via email to