Hey,
does any body have an example of hov to get at servlet to wait for
an answer from a http-server?
i have this class made for sending af reciving a requst from a
server, but i some times recive a null for the class return.
private String getDocument(String urlCode) {
try {
URL url = new URL(urlCode);
HttpURLConnection httpUrlConnection = (HttpURLConnection)
url.openConnection();
httpUrlConnection.disconnect();
//Set Header connection
httpUrlConnection.setDoInput(true);
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setRequestProperty("Content-Type","application/x-www-form-
urlencoded");
httpUrlConnection.setUseCaches(false);
/* httpUrlConnection.setRequestProperty("Set-Cookie", sessionInfo);
httpUrlConnection.setRequestProperty("sesessionid", sessionID);
sessionInfo =
httpUrlConnection.getHeaderField("Set-Cookie");
sessionID =
sessionInfo.substring(sessionInfo.indexOf("=")+1,sessionInfo.indexOf(";"));
pathCook =
sessionInfo.substring(sessionInfo.indexOf("path")+5,sessionInfo.indexOf(";")
);
domain =
sessionInfo.substring(sessionInfo.indexOf("domain")+7,sessionInfo.length());
System.out.println(sessionInfo);
System.out.println(sessionID);
System.out.println(pathCook);
System.out.println(domain);
*/ // Make connection
httpUrlConnection.connect();
InputStream inputStream =
httpUrlConnection.getInputStream();
int size = inputStream.available();
byte[] b = new byte[size];
inputStream.read(b);
String resp = new String(b);
inputStream.close();
return resp;
}
catch(Exception e) {
}
return null;
}
Does any body have any sugestions?
Kind regards
Anders J�rvad
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html