|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jfw.web.util.ExecuteUrl
public final class ExecuteUrl
Used for open an http connection.
Open connection via get
Open connection via post
//setting url and parameters
ExecuteUrl url = new ExecuteUrl("http://www.mysite.com", "myPage.do?username=usr&password=pwd");
//get all text returned from myPage.do
String output = url.readAll();
//closing streams
url.close();
//setting url
ExecuteUrl url = new ExecuteUrl("http://www.mysite.com", "myPage.do");
//setting parameters
url.write("username", "usr");
url.write("password", "pwd");
url.flush();
//get all text returned from myPage.do
String output = url.readAll();
//closing streams
url.close();
Constructor Summary | |
---|---|
ExecuteUrl(java.lang.String page)
Connect to a page via get. |
|
ExecuteUrl(java.lang.String proxy,
int proxyPort,
java.lang.String page,
java.util.HashMap requestParams)
Connect to a page via get using a proxy and request parameters. |
|
ExecuteUrl(java.lang.String host,
java.lang.String page)
Connect to a page via get. |
|
ExecuteUrl(java.lang.String host,
java.lang.String page,
java.util.HashMap requestParams)
Connect to a page via get using request parameters. |
|
ExecuteUrl(java.lang.String host,
java.lang.String page,
int port)
Connect to a page via post. |
Method Summary | |
---|---|
void |
close()
Close opened stream and the connection. |
void |
finalize()
Call method close() and super.finalize(). |
void |
flush()
Flush the socket, if post method is used, or the output stream. |
byte[] |
read()
Read input stream. |
java.lang.String |
read(int bytesToRead)
Read input stream. |
java.lang.String |
readAll()
Read all data of input stream. |
void |
write(java.lang.String name,
java.lang.String value)
Add a post parameter. |
void |
write(java.lang.String name,
java.lang.String value,
java.lang.String encode)
Add a post parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExecuteUrl(java.lang.String host, java.lang.String page, int port) throws JFWGenericException
host
- host name.page
- page to connect.port
- remote server port.
JFWGenericException
public ExecuteUrl(java.lang.String page) throws JFWGenericException
page
- the url to connect.
JFWGenericException
public ExecuteUrl(java.lang.String host, java.lang.String page) throws JFWGenericException
host
- host name.page
- page to connect.
JFWGenericException
public ExecuteUrl(java.lang.String proxy, int proxyPort, java.lang.String page, java.util.HashMap requestParams) throws JFWGenericException
proxy
- proxy to use.proxyPort
- proxy port. If -1 use default port.page
- page to connect.requestParams
- request parameters, ex. Authorization.
Set null for no parameters.
JFWGenericException
public ExecuteUrl(java.lang.String host, java.lang.String page, java.util.HashMap requestParams) throws JFWGenericException
host
- host name.page
- page to connect.requestParams
- request parameters, ex. Authorization.
JFWGenericException
Method Detail |
---|
public java.lang.String read(int bytesToRead) throws JFWGenericException
bytesToRead
- the number if bytes to read.
JFWGenericException
public byte[] read() throws JFWGenericException
JFWGenericException
public java.lang.String readAll() throws JFWGenericException
JFWGenericException
public void write(java.lang.String name, java.lang.String value, java.lang.String encode) throws java.lang.Exception
name
- the name of the parameter.value
- the value of the parameter.encode
- the encoding to use. If null then UTF-8 will be used.
java.lang.Exception
public void write(java.lang.String name, java.lang.String value) throws java.lang.Exception
name
- the name of the parameter.value
- the value of the parameter.
java.lang.Exception
public void flush() throws java.lang.Exception
java.lang.Exception
public void close()
public void finalize() throws java.lang.Throwable
close()
and super.finalize().
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |