Applet Servlet communication via HTTPS

N

Ng Wee Peng

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
 
D

Dave Miller

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top