File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Applet Servlet communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Applet Servlet communication" Watch "Applet Servlet communication" New topic

Applet Servlet communication

Sushant Kumar

Joined: Feb 13, 2004
Posts: 1
how applet can fetch data from servlet which is stored in servlet in a 2D Array.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Sushant,
Welcome to JavaRanch. Write the output on an ObjectOutputStream from the Servlet. Similiar to this:

Then on the Applet:

Note that any objects placed on the stream must implement
I'm moving this to the Servlet Forum.
[ February 25, 2004: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Apart from the mechanism mentioned by Michael, you can also use RMI and Socket Connection (if possible) for applet-servlet communication.

Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Harro deGouw

Joined: Feb 23, 2004
Posts: 5
Using custom (raw) sockets requires special permissions, you'd have to sign the applet to get these permissions or change the security settings in the browser.
imho it's generally a better idea to use the first mechanism...
I agree. Here's the link:
subject: Applet Servlet communication
It's not a secret anymore!