Hello Ben,
I did the following, but still have an connection error "
java.net.SocketException: Network is unreachable: connect". I'm not sure why this error, any ideas?
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String urlStr = new String ("http://api.clickatell.com/http/auth?api_id="
+ api_id + "&user="
+ username + "&password=" + password);
HttpServletResponseWrapper hsrw = new HttpServletResponseWrapper(res);
urlStr = res.encodeRedirectURL(urlStr);
BufferedReader in = null;
BufferedWriter out = null;
try {
URI uri = new URI(urlStr);
URL url = uri.toURL();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
String s = conn.getResponseMessage();
System.out.println(s);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (MalformedURLException e1){
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
} finally {
try {
out.close();
in.close();
} catch (IOException e3) {}
}
}
===============================
The exception occurred in
String s = conn.getResponseMessage();line.
----------------
thanks in advance.