wood burning stoves 2.0*
The moose likes Servlets and the fly likes Applet-servlet communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Applet-servlet communication" Watch "Applet-servlet communication" New topic
Author

Applet-servlet communication

Nasir Mkhan
Greenhorn

Joined: May 13, 2001
Posts: 28
Hello all of you.
I am developing online chess game in which two players can play with each other using chess applet through servlet.How can i send the parameters received from one applet to another and vice versa in order to repaint the applet to show the action of other?
Can anyone plz tell me.
Thanks in any case.
Tero Ahonen
Greenhorn

Joined: May 24, 2001
Posts: 26
Use javaranch's own com.javaranch.common package (http://www.javaranch.com/common.jsp). There is couple of classes (ObjectServlet, HTTP, etc.) which can be used for applet-servlet-applet communication.
-Tero


-Tero
Hemant Bhaiya
Greenhorn

Joined: Nov 01, 2000
Posts: 21
You want to know Applet-Applet communication or Applet-servlet communication?
Please clarify.
Luv,
Hemant
Mohamed Yousuff
Ranch Hand

Joined: Jun 23, 2001
Posts: 73

There is a way to solve this problem. You have to develop a servlet which will store the action of the players in a session. The applet which comes to the front end in the client browser window will run a thread which will contact the servlet and retrieve the latest changes from the opposite side. This should be done in a separate thread and should be repeated every few seconds. There are some ways for the applet to contact the servlet. It can use the HttpUrlConnection in the java.net package or use rmi or use socket. You need to consider these techniques based on your requirements. Note that this problem is not new. This is typical of an online chat application using applets.

Originally posted by Abdul Nasir:
Hello all of you.
I am developing online chess game in which two players can play with each other using chess applet through servlet.How can i send the parameters received from one applet to another and vice versa in order to repaint the applet to show the action of other?
Can anyone plz tell me.
Thanks in any case.


------------------
Raghvendra Sharma
Ranch Hand

Joined: Oct 09, 2000
Posts: 82
Hi,
I have developed an applet, that fetches data from the servlet (really a huge chunk) and then posts at regular intervals. Its actually a test applet.
I have used the serialization funda for passing data between applet and servlet.
It has worked good for me without problems.
You can also try it
1. open a urlconnection to the servlet
2. get the output stream of the connection, with output enabled
3. create an object output stream with url con.'s o/p stream as parameter
4. write to objectoutput stream your object. (your obj. must be serializable )
similarly read from the urlcon.'s input stream.

Hope it helps.
thanks n regards
raghav..
[This message has been edited by Raghvendra Sharma (edited June 26, 2001).]
Nasir Mkhan
Greenhorn

Joined: May 13, 2001
Posts: 28
Thanks to all.
I have got the point to check.
Thanks once again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet-servlet communication