It's just a code snippet from one of my servlets.. It works fine...

Mvgr,
Martin

   Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.ww
w.protocol");
    String url = "https://<servername>";
    // let's connect to the url
    InputStream is = null;
    dbg.writeln("Status : PAY"+status);
    int maxretries = Integer.parseInt(tdps.get("PAY-"+status,"maxretries"));
    is = letsconnect(is, urltosend.toString());
    maxretries-=1;
    while ( is == null) {
      if (maxretries==0) {
        System.out.println("Error: Unable to connect");
        resp.sendRedirect(tdoffline);
        return;
      }else{
        // a small brake for a couple of second could be nice
        dbg.writeln("attempting to get something from td");
        is = letsconnect(is, urltosend.toString());
        maxretries-=1;
      }
    }
  while(is.available() == 0) {};
    byte[] b = new byte[is.available()];
    is.read(b);
    String bs = new String(b);
    dbg.writeln("Open returned : "+ bs);
      return;
    }

  public InputStream letsconnect(InputStream is,String urltosend) throws
IOException {
    try {
      is = new URL(urltosend.toString()).openConnection().getInputStream();
    }
    catch (IOException e) {
      dbg.writeln("Error : creating new connection "+String.valueOf(e));
    }

    return is;
  }

> -----Original Message-----
> From: Steven Banks [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 24, 2001 3:43 PM
> To: '[EMAIL PROTECTED]'
> Subject: HTTPS connections from servlet
>
>
> I am having severe trouble getting my application to access a secure
> web-server from within one of my servlets.
>
> I have installed all the necessary JSSE jar files, set the properties:
>
>     System.setProperty("java.protocol.handler.pkgs",
>                        "com.sun.net.ssl.internal.www.protocol");
>     java.security.Security.addProvider(
>               new com.sun.net.ssl.internal.ssl.Provider());
>
> ... and tried fiddling around with the proxy properties, to no avail.
>
> In order to allow this functionality, do we need to build an SSL enabled
> tomcat instance? Or am I missing something more fundamental. The code runs
> fine outside of Tomcat BTW.
>
> I've searched the net high and low for answers, but found none. ANy help
> would be most appreciated. Oh, we're using tomcat 3.2.1 on NT4.
>
> Regards
> Steve Banks
>

Reply via email to