In the code fragment below, the client will use os to upload data to the web service provider.
Choose the statement that must be placed in line 5, to ensure this fragment works as intended.
(Choose one)
A.
connection.setDoOutput(true);
B.
connection.setAllowUserInteraction(true);
C.
connection.setIfModifiedSince(new Date().getTime());
D.
connection.setUseCaches(false);
im not sure, but i think A. connection.setDoOutput(true);
A
What exactly does URLConnection.setDoOutput() affect?
You need to set it to true if you want to send (output) a request body, for example with POST or PUT requests. With GET, you do not usually send a body, so you do not need it.
Sending the request body itself is done via the connection’s output stream:
conn.getOutputStream().write(someBytes);