Hi,
I'm been trying to solve below problem around one week without success... Please, help me...
The problem is that I should transfer (chipered) data between
applet and
servlet by using post-method. The applet has code like below and it invokes the doPost-method on servlet, but I'm not able to get any data transferred. See codes below:
APPLET:
URL url = new URL(baseURL, servletName);
HttpURLConnection sc = (HttpURLConnection) url.openConnection();
sc.setRequestMethod("POST");
sc.setDoOutput(true);
sc.setDoInput(true);
sc.setUseCaches(false);
sc.setDefaultUseCaches(false);
sc.setAllowUserInteraction(false);
sc.setRequestProperty ("Content-Type", "application/octet-stream");
sc.setRequestProperty("Content-length", String.valueOf(10));
InputStream in = sc.getInputStream();
OutputStream out = sc.getOutputStream();
out.write("cipherdata".getBytes());
out.flush();
out.close();
...
in.close();
doPost-Method in SERVLET:
ServletInputStream in = request.getInputStream();
ServletOutputStream out = response.getOutputStream();
//next two line works ok...
System.err.println("Type: " + request.getContentType());
System.err.println("Content Length: " + request.getContentLength());
//but this do not return any bytes (jams) and also
//in.availabel()- function returns 0.
System.err.println("Read byte: " + in.read());
...
Everything should be ok, but just do not work. I'm quite beginner with
Java and do not know is the problem my competence, web-server (Apache Tomcat/4.0-b1) or what. Please, help me.
Regards,
Jorma Ikonen