•
•
•
•
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
![]() |
•
•
Join Date: May 2007
Posts: 12
Reputation:
Rep Power: 2
Solved Threads: 0
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();
}
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();
}
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."
"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."
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Accepting audio in a java servlet (Java)
- Servlet(receiving audio) (JSP)
- Capturing CD audio (Game Development)
- Sending audio data over HTTP problem (Java)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: javascript code
- Next Thread: calculate difference of 2 dates


Linear Mode