Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Applet/Servlet communication

Started by Icculus Aug 3, 2000 at 6:17 PM 7 replies 950+ views
Original Post
Icculus
Icculus
Can someone give me a hand in applet/servlet communication. I can only find one source http://gamelan.earthweb.com/journal/techworkshop/020300_appserv2.html and this code I have played with but I can''t get his code to work by itself or integrated with mine. I have tried using Sockets and this works great in AppletViewer, but in IE I am getting SecurityExceptions. Can someone give me some code or a source for this type of thing without having to set permissions up to do it. Note that I don''t want the servlet to send back a html doc like all the tutorials but a stream such as a ObjectOutputStream so I can send things across. Thanks
author of the Helping Phriendly Book
joeG
joeG
How were you running it? You should have the servlet on the same server as where you put your webpage for it to work properly. Some web hosting services allow you to do that, others don''t. You might want to check into that. Sandbox rules only allow you to connect to the machine that the applet''s class came from.

Anyways, forgive me if you knew this, but the above solution immediately popped up in my head when I read your request for help.

joeG
joeG
Icculus
Icculus
thanks but nevermind, it was a dumb error on my part. I put the servlet in the servlets directory in the jdsk server and thought that was the directory to access it. I actually is the address/servlet for some wierd reason instead. Anyway I tried the above page and got a exception too, since it uses datagram sockets. I guess I''ll have to do http communication but it is not as good as Sockets since the applet had to refresh every so often to get info. Has anyone used Sockets without security problems between a applet and a servlet?
author of the Helping Phriendly Book
Jim_Ross
Jim_Ross
I have done applet to server communication. I haven''t bothered with the servlet part. It seems rather overkill to wrap you server behind an http server.
Bruce
Bruce
If you use the javax.servlet API, you will probably use the javax.servlet.http.HttpServlet class that generates HTTP content. Instead, use the javax.servlet.GenericServlet and implement the service method.Good links:
http://java.sun.com/products/servlet/?frontpage-javaplatform
http://java.sun.com/products/servlet/2.2/javadoc/index.html
Neurotic
Neurotic
I''ve done applet to server communication before as well... I think it was a simple chat app.

I wonder what your doing thats causing the Security Exception?

Can we get some code?

Mark

----
http://go.to/e[m]anate
----
<< ...and here is one we developed earlier... >>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.