Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating multiple fields in applets

 
Joe Guzzardo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Joe Guzzardo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic