Applet Servlet communication via HTTPS

Discussion in 'Java' started by Ng Wee Peng, Apr 1, 2004.

  1. Ng Wee Peng

    Ng Wee Peng Guest

    Hello,

    I have an applet that communicates with a Servlet in the web server.
    The web server has been configured for secured access by SSL. I am
    unable to get the applet to communicate with the servlet over HTTPS. I
    would appreciate any help or pointers in solving this problem.

    Right now, the applet talks to the servlet over normal HTTP and it
    works fine. However, when I switch the communication protocol to
    HTTPS, I get this error message in the Java console:

    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext
    connection?

    I am using Java plugin 1.4 on an Internet Explorer 6 browser.
    Java(TM) Plug-in: Version 1.4.2
    Using JRE version 1.4.2 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\ngwp

    Proxy Configuration: No proxy

    Here is an excerp of the applet code that communicates with servlet.
    The applet is sending an object to the servlet, and is expecting an
    object in return from the Servlet.

    URL url = new URL("https://somesite:80/TestServlet?param=test");
    URLConnection servletConnection = url.openConnection();
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setDefaultUseCaches(false);
    servletConnection.setRequestProperty("Content-Type",
    "application/octet-stream");

    if (obj != null) {
    ObjectOutputStream outputToServlet = new ObjectOutputStream(
    servletConnection.getOutputStream());
    outputToServlet.writeObject(obj);
    outputToServlet.flush();
    outputToServlet.close();
    }

    ObjectInputStream inputFromServlet = new ObjectInputStream(
    servletConnection.getInputStream());
    Object objreceived = inputFromServlet.readObject();
    inputFromServlet.close();


    Thanks
    Ng Wee Peng, Apr 1, 2004
    #1
    1. Advertising

  2. Ng Wee Peng

    Dave Miller Guest

    In article <>,
    says...
    > Hello,
    >
    > I have an applet that communicates with a Servlet in the web server.
    > The web server has been configured for secured access by SSL. I am
    > unable to get the applet to communicate with the servlet over HTTPS. I
    > would appreciate any help or pointers in solving this problem.
    >
    > Right now, the applet talks to the servlet over normal HTTP and it
    > works fine. However, when I switch the communication protocol to
    > HTTPS, I get this error message in the Java console:
    >
    > javax.net.ssl.SSLException: Unrecognized SSL message, plaintext
    > connection?
    >
    > I am using Java plugin 1.4 on an Internet Explorer 6 browser.
    > Java(TM) Plug-in: Version 1.4.2
    > Using JRE version 1.4.2 Java HotSpot(TM) Client VM
    > User home directory = C:\Documents and Settings\ngwp
    >
    > Proxy Configuration: No proxy
    >
    > Here is an excerp of the applet code that communicates with servlet.
    > The applet is sending an object to the servlet, and is expecting an
    > object in return from the Servlet.
    >
    > URL url = new URL("https://somesite:80/TestServlet?param=test");
    > URLConnection servletConnection = url.openConnection();
    > servletConnection.setDoInput(true);
    > servletConnection.setDoOutput(true);
    > servletConnection.setUseCaches(false);
    > servletConnection.setDefaultUseCaches(false);
    > servletConnection.setRequestProperty("Content-Type",
    > "application/octet-stream");
    >
    > if (obj != null) {
    > ObjectOutputStream outputToServlet = new ObjectOutputStream(
    > servletConnection.getOutputStream());
    > outputToServlet.writeObject(obj);
    > outputToServlet.flush();
    > outputToServlet.close();
    > }
    >
    > ObjectInputStream inputFromServlet = new ObjectInputStream(
    > servletConnection.getInputStream());
    > Object objreceived = inputFromServlet.readObject();
    > inputFromServlet.close();
    >
    >
    > Thanks
    >

    Use class javax.net.ssl.HttpsURLConnection
    --
    Dave Miller
    FundablePlans - Create a custom business plan online - only $39.95
    http://www.fundableplans.com
    Dave Miller, Apr 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rui Pacheco

    Applet to servlet communication

    Rui Pacheco, Oct 22, 2003, in forum: Java
    Replies:
    2
    Views:
    5,409
  2. Mustafa Aydin

    Applet <==> Servlet Communication

    Mustafa Aydin, Nov 18, 2003, in forum: Java
    Replies:
    7
    Views:
    4,264
    Nigel Wade
    Nov 20, 2003
  3. Troy
    Replies:
    4
    Views:
    4,217
    Nigel Wade
    Jul 19, 2004
  4. shahram
    Replies:
    3
    Views:
    786
    shahram
    Sep 20, 2004
  5. MattC
    Replies:
    11
    Views:
    4,601
    HalcyonWild
    Oct 14, 2005
Loading...

Share This Page