Java applet communicate with servlet on tomcat server?

If your application doesn't need real-time communication with a server over a raw socket (and it sounds like yours does not), you might be better off using standard web protocols for your applet to communicate with the server One choice might be HTTP/JSON. Your applet could make an HTTP connection to a servlet, and that servlet will generate a JSON object that represents a message the server wants to send to the client. The client will start a thread that will loop, making an asynchronous blocking call to your servlet to poll for new data The major advantage of this approach, is that in the future, should you be so inclined, you can ditch the client-side java applet, and replace it with HTML5 and Javascript GSON is a library to use for JSON serialization/deserialization.

And java.net. URL is what you would use to connect to the servlet inside your applet.

If your application doesn't need real-time communication with a server over a raw socket (and it sounds like yours does not), you might be better off using standard web protocols for your applet to communicate with the server. One choice might be HTTP/JSON. Your applet could make an HTTP connection to a servlet, and that servlet will generate a JSON object that represents a message the server wants to send to the client.

The client will start a thread that will loop, making an asynchronous blocking call to your servlet to poll for new data. The major advantage of this approach, is that in the future, should you be so inclined, you can ditch the client-side java applet, and replace it with HTML5 and Javascript. GSON is a library to use for JSON serialization/deserialization.

And java.net. URL is what you would use to connect to the servlet inside your applet.

I would be fine with just passing simple text messages between the two and using a switch to process what action to take. Also any you can say about my tomcat questions? – Sbram Jun 17 at 19:32 @Sbram devdaily.

Com/java/edu/pj/pj010023 has useful examples. And Tomcat doesn't add anything special, you'll just be using it as a standard servlet container. – ironchefpython Jun 17 at 19:35.

Yes. What you are describing is applet-servlet communication. Typically, your applet will send messages to the servlet which will then keep track of communicating with all the other client applets.

There are several examples of applet-servlet communications online. Here is one -- old, but still valid and the code is not formatted. docstore.mik.ua/orelly/java-ent/servlet/... There are security restrictions around applets and the servers they can communicate to, so thats something else to keep in mind.

Basically could you provide some more clarification for question 3 please. – Sbram Jun 17 at 18:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions