This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Applet-servlet communication

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want to know Applet-Applet communication or Applet-servlet communication?
Please clarify.
Luv,
Hemant
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.



------------------
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all.
I have got the point to check.
Thanks once again.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic