This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes Updating multiple fields in applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Updating multiple fields in applets" Watch "Updating multiple fields in applets" New topic
Author

Updating multiple fields in applets

Joe Guzzardo
Ranch Hand

Joined: Mar 14, 2000
Posts: 57
I have an applet that need to communicate with a servlet. I know how to update a single text field in the applet from data returned by the servlet. I also know how to create an html table from the servlet that can be displayed alongside the applet panel. My question: how do i update multiple text fields in the applet from data returned by the call to the servlet?

Thanks and regards, Joe
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Presumably, you just send some marked-up data from the servlet, and let the Applet split it into the appropriate fields.
I find that the simplest way to do this is to use the built in "Properties" class. Build a Properties object on the server (it's like a Hashtable, so just use put(name, value)), then use it's 'save' (or 'store' in Java2) method to write itself out to the output stream. In the Applet, create a new Properties object and use 'load' to parse the incoming stream, then set the applet fields from the Properties data.
Is this what you are looking for?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Joe Guzzardo
Ranch Hand

Joined: Mar 14, 2000
Posts: 57
Thanks Frank, you make it sound so easy, ahh the joy of se.. I mean Java, let me give that a try. Also can you recommend any good books on Servlet programming? I just purchased Java Servlet Programming by Jason Hunter (published by O'Reilly) it seems pretty good.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Paul has reviewed several Servlet books in the "bunkhouse". Yes, there is a web site outside this board .... Personally, I use Hunter, if anything, but (unless you have a new edition) it's not quite up to date with some of the latest APIs.
 
 
subject: Updating multiple fields in applets