Hello Everybody,

I have to communicate with a servlet from an Applet. I am using the
following code to call the doPost method of
a servlet inside an Applet but it is not working i.e. the doPost method of
the servlet is not called at all (I discovered
after debugging).
The applet itself is called inside the doGet method of the same servlet
which is sending an HTML page
inside which the Applet is embedded. Can anyone help me please.

Code Listing
      java.net.URL url = new java.net.URL(codeBase + servlet);
      java.net.URLConnection con=url.openConnection();
      con.setUseCaches(false);
      con.setDoOutput(true);
      con.setDoInput(true);
      ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
      DataOutputStream out = new DataOutputStream(byteOut);
      out.writeUTF(sessionId);
      out.writeUTF(user);
      out.writeUTF(pw);
      out.flush();
      byte buf[] = byteOut.toByteArray();
      con.setRequestProperty("Content-type", "application/octet-stream");
      con.setRequestProperty("Content-length","" + buf.length);
      DataOutputStream dataOut = new
DataOutputStream(con.getOutputStream());
      dataOut.write(buf);
      dataOut.flush();
      dataOut.close();

Thanks,

Satyan Prakash
Software Engineer
ITIL

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to