This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
How can I have an applet that can request data from a server directly? I have a JApplet that displays some drawings made through AWT. I want to have some links on the drawing that can "lookup" data from the server, directly from the applet and return it. What choices do I have to accomplish this? Suggestions are appreciated. Thanks.
Have you read this part of the Oracle tutorial regarding Applets?
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Maki Jav
Ranch Hand
Joined: May 09, 2002
Posts: 423
posted
0
Well You can have those drawings put up in icons or labels and call mouseClicked events on the and have a method that sends request to some servlet on the server. The servlet then returns some data in string or Object form and the Applet then displays it in its assigned place. If that is an Object that server sends and applet reads, then you have to have the Class file of that Object too with the applet.
I can further help you if you tell me what you need...
Maki Jav
Help gets you when you need it!
Rob Hunter
Ranch Hand
Joined: Apr 09, 2002
Posts: 788
posted
0
If I had a simple as possible example I could work from that. So basically a JApplet that (upon clicking a JButton) would make a call directly to the server, read a textfile with first name and last name in it, and display a popup with those 2 values in it. I've read about RMI but with RMI you would need to download a jar file onto the client (correct?) and that's not something I want to do (don't want to have people download additional requirements). I just want to have an app in JApplet app that resembles a html page that utilizes AJAX (i.e. doesn't need to refresh and can directly grab info from the server behind the scenes). Does that help? If you have any additional info I'd appreciate it if you could pass it along. Thanks for your post as well.
Maki Jav
Ranch Hand
Joined: May 09, 2002
Posts: 423
posted
0
Well it is either JApplet or Ajax; not Applet and Ajax; got me?
Well that is easy to build.
Have a server response on your server side like Servlet...
Heard that JApplet can read file from that same url from which it is loaded. And I have worked on it too.
Read textfile from url through applet and display it.
I will have to write code for you?
Maki Jav
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35246
7
posted
0
The http://www.coderanch.com/how-to/java/CodeBarnApplets page has an example applet that reads a file from a server and processes its contents. Instead of a static URL, the applet could as well access a servlet that returns dynamic content.