Class HttpPost
java.lang.Object
|
+----HttpPost
- public class HttpPost
- extends Object
A class representing for posting information to web servers.
For example:
HttpPost hpost= new hpost("http://130.9.15.26/vrs/hello.cgi");
- See Also:
- util, io
-
HttpPost(String)
- Opens connection to the URL specified in String.
-
end()
- Submit necessary characters to indicate the end of Post method
-
init()
- Opens connection to the URL specified.
-
readResponse()
- Get the response from the server.
-
sendField(String, String)
- Send a field to the server
-
sendFile(String, String)
- Send a file to the server
-
setPassword(String)
- For web site that requires authentication only.
-
setProxy(String, String)
- Change the proxy setting.
-
setUser(String)
- For web site that requires authentication only.
-
useProxy(boolean)
- By default, this class use the proxy for all HTTP
connections.
HttpPost
public HttpPost(String urlstr)
- Opens connection to the URL specified in String.
init
public void init()
- Opens connection to the URL specified. Opens the DataOutputStream and
DataInputStream.
- Returns:
- None.
- Throws: MalformedURLException
- if the index is not in the range
0
to length()-1.
- See Also:
- openConnection
sendFile
public void sendFile(String fileName,
String value)
- Send a file to the server
- Parameters:
- fileName - is the name of the file to send.
value is the name of the field that accepts the file.
- Returns:
- None.
- Throws: StringIndexOutOfRangeException
- if the index is not in the range
0
to length()-1.
- See Also:
- charValue
sendField
public void sendField(String fieldName,
String value)
- Send a field to the server
- Parameters:
- value - is the content to send.
fieldName is the name of the field that accepts the file.
- Returns:
- None.
- Throws: StringIndexOutOfRangeException
- if the index is not in the range
0
to length()-1.
- See Also:
- Character
end
public void end()
- Submit necessary characters to indicate the end of Post method
- Returns:
- None.
- See Also:
- close
readResponse
public DataInputStream readResponse()
- Get the response from the server.
- Returns:
- DataInputStream
- See Also:
- getInputStream
useProxy
public void useProxy(boolean proxy)
- By default, this class use the proxy for all HTTP
connections. To disable proxy, use useProxy(false)
- Parameters:
- true - to enable proxy connection; false to disable.
- Returns:
- None.
- See Also:
-
setProxy
public void setProxy(String proxy,
String portnum)
- Change the proxy setting. By the default, the proxy
name is proxy and the port number is 3128
- Parameters:
- proxy - is the name of proxy, eg "proxy.singnet.com.sg'.
portnum is the port number of the proxy.
- Returns:
- None.
- See Also:
-
setPassword
public void setPassword(String pwd)
- For web site that requires authentication only. User need to
supply the password.
- Parameters:
- pwd - is the password string.
- Returns:
- None.
setUser
public void setUser(String username)
- For web site that requires authentication only. User need to
supply the User ID.
- Parameters:
- username - is the user ID string, eg "Anonymous"
- Returns:
- None.