This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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
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.
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).]
Joined: May 13, 2001
Thanks to all. I have got the point to check. Thanks once again.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com