PDA

View Full Version : SSL connection using java


Forever Zero
07-25-2008, 05:31 PM
Hello all,

I have this method to grab an InputStream containing the HTML of a web page:


/**
* Get an InputStream of HTML from a URL
* @param urlString the URL to get HTML from
*/

private static InputStream getIS(String urlString) {
try {
URL url = new URL(urlString);
java.net.HttpURLConnection httpURL = ( java.net.HttpURLConnection ) url.openConnection();
httpURL.setRequestProperty ( "User-Agent", "Mozilla/5.0 ( compatible ) " );
InputStream inputStream = httpURL.getInputStream();
return inputStream;
} catch (IOException ex) {
return null;
}
} // getIS


I was wondering if there is a way to do this same thing, but use an SSL connection?

Any would would be much appreciated.

ess
07-28-2008, 01:39 PM
Please see this page for an example
http://www.websphere-world.com/modules.php?name=News&file=article&sid=327

See also Nokia Docs on using HTTP and HTTPS on Java ME
http://wiki.forum.nokia.com/index.php/Using_Http_and_Https_in_Java_ME

Hope this helps

Cheers
~E

Forever Zero
07-28-2008, 05:01 PM
Thanks a lot, that helps me out quite a bit :)