• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet servlet comunication

 
grandhi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in how many ways apllets will comunicate with servlets.
 
Matt Midcap
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the "Applets" forum.
Also, please see our naming policy (http://www.javaranch.com/name.jsp), re-register and do come back to see us again.
Matt
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I know one way how the communication works. It is something like this:
<pre><code>
//create URL for get and pass name=value pair if you need to
String serverurl=serveraddress+"?name=value&name=value";
URL url=new URL(getDocumentBase(),serverurl);
URLConnection connect=url.openConnection();
//for writing through post enter the date in the body
DataOutputStream out=new DataOutputStream(con.getOutputStream());
//optional
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
//bytes is an array of byte
out.writeBytes(bytes);
out.flush();
out.close();
//for reading from the servlet
InputStram in=con.getInputStream();
</code></pre>

see the applet-servlet communication chapter in O'reilly's Servlet Programming for more details.
bye
Tanveer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic