KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > microedition > io > HttpsConnection

javax.microedition.io
Interface HttpsConnection

All Superinterfaces:
Connection, ContentConnection, HttpConnection, InputConnection, OutputConnection, StreamConnection
See Also:
CertificateException

public int getPort()
See Also:
HttpConnection
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1914]
By iqueen on 2007/08/06 22:25:44  Rate
private static final int RETRY = 3; 
  
  
     /** 
      * open a Connection by given URL, retry 3 times 
      *  
      * @param URL 
      * a String of a URL 
      * @return Connection or null 
      */
 
     private static Connection openConnection ( String URL )   {  
         Connection cnn = null; 
         for  ( int i = 0; i  <  RETRY; i++ )   {  
             try  {  
                 cnn = Connector.open ( URL ) ; 
                 break; 
  
  
              }  catch  ( ConnectionNotFoundException e )   {  
                 // ignored, keep retrying 
              }  catch  ( IOException e )   {  
                 // TODO Auto-generated catch block 
                 e.printStackTrace (  ) ; 
              }  catch  ( SecurityException e )   {  
                 break; 
              }  
          }  
         return cnn; 
      }  
  
  
     public static HttpConnection openHttpsConnection ( String URL )   {  
         return openHttpsConnection ( URL, null ) ; 
      }  
  
  
     /** 
      * open a HTTPS connection for given URL with given method 
      *  
      * @param URL 
      * a string of URL 
      * @param method 
      * a string of https connection method 
      * @return an object of https connection 
      */
 
     private static HttpConnection openHttpsConnection ( String URL, String method )   {  
         Connection connection = openConnection ( URL ) ; 
         HttpsConnection httpsConnection = null; 
  
  
         httpsConnection =  ( HttpsConnection )  connection; 
  
  
         if  ( method != null )   {  
             try  {  
                 httpsConnection.setRequestMethod ( method ) ; 
              }  catch  ( IOException e )   {  
                 // TODO Auto-generated catch block 
                 e.printStackTrace (  ) ; 
              }  
          }  
         return httpsConnection; 
      }  
  
  
 


public SecurityInfo getSecurityInfo()
                             throws java.io.IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags