Java. Lang. illegalstateexception: Write attempted after request finished
For HTTP connections, only one read/write can be performed, and the input stream can be opened for read operations only after the write is completed.
Int responsecode = conn. getresponsecode ();
Dataoutputstream dos = conn. opendataoutputstream ();
Dos. writeutf (name );
Dos. writeutf (passwrod );
Dos. Flush ();
This sectionCodeMedium
Set int responsecode = conn. getresponsecode ();
Put it at the end, that is, write and then request to return data
==================
1. How about actually closing a connection before opening a new one?
2. IT/'s HTTP, not a socket, you can/'t keep sending and processing data. IT/'a question answer gave. after the answer, you cannot state another question without a reconnect (or use HTTP 1.1, but that shoshould be transparantly ). even though you set the keep-alive request propery
3. A post works in this oder:
-Init your headers
-Open output steam
-Write Data
-Check response code
-Open input stream
-Read data
-Close all