Hello Rob, Alex and others,

Thanks a lot for your help but I am still not able to solve the problem. I
tried the con.setRequestProperty( "Content-type", "text/html") as suggested
by Alex , I tried the con.connect() as suggested by Rob, where con is an
object of class  java.net.URLConnection but it is still not working. Can
anyone help me please? I am under tremendous pressure to complete this
assignment. I am sending the problem again

> > 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

___________________________________________________________________________
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