Slide 5.2: Network connection (cont.) Slide 5.4: Network connection (cont.) Home |
public interface HttpConnection extends javax.microedition.io.ContentConnectionThe HTTP protocol is a request-response application protocol in which the parameters of the request must be set before the request is sent. The connection could be in one of the three following states:
Setup
: No connection yetConnected
: Connection has been made, the request has been sent, and some response is expected.Closed
: Connection is closed.
Setup
state, the following methods can be invoked:
public void setRequestMethod( String method ) public void setRequestProperty( String key, String value )For example, suppose you have this connection:
HttpConnection c = ( HttpConnection ) Connector.open( "http://java.sun.com/developer" );Then, you can set the request method to be of type
POST
as follows:
c.setRequestMethod( HttpConnection.POST );