Basically, a Java servlet is the equivalent of the next PHP line, which is the key line in the code,
$content = file_get_contents('php://input');
is an
InputStream input = request.getInputStream();
This returns basically a single HTTP request object. You can write it to an arbitrary OutputStream
usual Java way. For example, a new FileOutputStream("/some.wav")
.
You should understand that the body of an HTTP request can only be read once, and that it will be implicitly parsed when you call any of the request.getParameterXxx()
methods. Therefore, if you are also interested in the parameters in the query string of the request URI, you should use instead
String queryString = request.getQueryString();
and analyze it further (i.e. divide by &
, then divide by =
, then URLDecode
name and value).
source share