[java] Applet/Servlet communication

Started by
7 comments, last by Icculus 23 years, 6 months ago
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
Advertisement
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
Try this link... http://java.sun.com/docs/books/tutorial/applet/practical/server.html

I don''t know if that''s quite what you''re looking for.

War doesn't determine who is right, war determines who is left.
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
I know it is possible... I read something on it, but cannot remember where. Is the applet being served off of the same server that the servlet resides on? That can cause problems with security
I''m trying to find some good information about this subject too. I have to transfer binary data from my applet to a servlet, but I haven''t been able to find any information about it. All I''ve been able to find, is comments about a supposedly great book from o''reilly. Anyone have the book "Java Servlet Programming"? I''d like to know whether or not it contains any valuable info about the subject.
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.
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
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... >>

This topic is closed to new replies.

Advertisement