hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niti Bhatt \(PL/EUS\)" <niti.bh...@ericsson.com>
Subject Problem using PostMethod
Date Wed, 31 Jan 2007 21:16:33 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message