Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9113361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:56:48+00:00 2026-06-17T03:56:48+00:00

Brief Story: I have a Servlet which receives a request (getContentType() = audio/x-wav) that

  • 0

Brief Story:
I have a Servlet which receives a request (getContentType() = audio/x-wav) that I can’t read. I need to read this wave and save it on the server side.

Detailed Story:
I know nothing about Flex, javascript, PHP and Python, I want to record (from the client side “Browser”) a wave file and send it to the server to save it (for further ASR processing).

After some searching I found a library called Wami-Recorder (uses flex and java scrip) which I already used, but it didn’t give me any java server side example, it also lacks the documentation so I decided to get my hands dirty to get it working.
it contains a server side python and PHP example (I will list the PHP one):

<?php    
# Save the audio to a URL-accessible directory for playback.    
parse_str($_SERVER['QUERY_STRING'], $params);    
$name = isset($params['name']) ? $params['name'] : 'output.wav';    
$content = file_get_contents('php://input');    
$fh = fopen($name, 'w') or die("can't open file");    
fwrite($fh, $content);    
fclose($fh);    
?>    

A final note is that I am sure if I created a socket server and directed the request to it, I will be able to get the media easily, but I want everything to be handled by the Servlets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:56:49+00:00Added an answer on June 17, 2026 at 3:56 am

    Basically, the Java servlet equivalent of the following line of PHP, which is the key line in the code,

    $content = file_get_contents('php://input');    
    

    is

    InputStream input = request.getInputStream();
    

    This returns basically the sole HTTP request body. You can write it to an arbitrary OutputStream the usual Java way. For example, a new FileOutputStream("/some.wav").

    You should only realize that the HTTP request body can be read only once and also that it would implicitly be parsed when you invoke any of the request.getParameterXxx() methods. So if you’re interested in the parameters in the request URI query string as well, then you should instead use

    String queryString = request.getQueryString();
    

    and parse it further yourself (i.e. split on &, then split on =, then URLDecode the name and value).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long story as brief as possible... I have an existing application that I'm trying
In brief, I need to do something like this: I have a folder with
brief overview so this is in context, I have an application in java that
Here's a brief rundown of my issue: I have a JavaScript function that gets
Long story coming up, but I'll try to keep it brief. I have many
i dont quite understand this pattern. from what i have read, it looks like
Brief : I have code which works if I don't dispose of the BindingSource
Brief background: I have two-step login page, which after step 1 sends one-time code
Given a table of models 'A', that can have multiple child models 'B', of
Brief question What command can I use to make my DataSet refresh it's connection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.