using URLHttpsConnection

Hi

where can I find source codes to do SSL session for servlets  using URLHttpsConnection.

Presently I am using URLHttpConnection to access and return data in a servlet.


How can I get it SSL enabled.
TLTEOAsked:
Who is Participating?
 
phlcCommented:
0
 
objectsCommented:
Grab JSSE from Sun it supports SSL:
http://java.sun.com/products/jsse/
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
TLTEOAuthor Commented:
they don't have the examples really, on URLHttpsConnection.
0
 
objectsCommented:
If your using JSSE then it's all transparent. You just specify the (https) url you require and use URLConnection the same as you would for standard http.

URL secure = new URL("https://tlteo.com/my.html");
URLConnection conn = secure.openConnection();
...
0
 
TLTEOAuthor Commented:
yeap i know,, but I am using apache with tomcat, and I dont use mod_ssl.  I am trying to use jsse to create a SSL session.

Seems like the crucial part is the PrintWriter out PrintWriter out;
     
            res.setContentType("text/html");
            out = res.getWriter();

How can I link
 
socket.startHandshake();
         PrintWriter out = new PrintWriter(
                      new BufferedWriter(
                      new OutputStreamWriter(
                           socket.getOutputStream())));

         SSLSocket socket =
          (SSLSocket)factory.createSocket(tunnel, host, port, true);



         

0
 
objectsCommented:
Are you trying to write SSL?
Sorry I thought you were trying to read SSL.
0
 
TLTEOAuthor Commented:
it is tuff writing this using URLHttpsConnection.  But anyway, I am trying to install a self signed cert into the system and test it.  more problems to come . Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.