User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,147 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,157 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 783 | Replies: 2
Closed Thread
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
 
Join Date: Jan 2007
Posts: 2,510
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 103
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Servlet(accepting audio)

  #2  
May 25th, 2007
What language is that? It's not JavaScript.
Daylight-saving time uses more gasoline
 
Join Date: Jun 2006
Location: India
Posts: 6,767
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 329
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Servlet(accepting audio)

  #3  
May 27th, 2007
Last edited by ~s.o.s~ : May 27th, 2007 at 12:32 pm.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
 
Closed Thread

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)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC