RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 849 | Replies: 2
Join Date: May 2007
Posts: 12
Reputation: kahilw is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
kahilw kahilw is offline Offline
Newbie Poster

Question Servlet(accepting audio)

  #1  
May 24th, 2007
The function below is sending audio that has been converted into bytes and then placed into a byte array, after which it is placed in the DataoutputStream and sent to a servlet. My question is How do I make a servlet that will receive this data and then turn it back into a format that can play audio?

Please help me!!!


void sendPostRequest(byte[] requestaudio)
{
HttpConnection hc = null;
DataInputStream dis = null;
DataOutputStream dos = null;

//URL to servlet
private static String defaultURL =
"http://localhost:8080/Speech/WEB-INF/classes/Speech";


// Open up a http connection with the Web server
// for both send and receive operations
hc = (HttpConnection)
Connector.open(defaultURL, Connector.READ_WRITE);

// Set the request method to POST
hc.setRequestMethod(HttpConnection.POST);

// Send the string entered by user byte by byte
dos = hc.openDataOutputStream();
byte[] request_body = requestaudio;

for (int i = 0; i < request_body.length; i++)
{
dos.writeByte(request_body[i]);
System.out.println("Packaging the bytes: " + request_body.length); //+ i);

}


dos.flush();
dos.close();
}
AddThis Social Bookmark Button
 

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:36 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC