Given that an applet is restricted to the server it was loaded from, how to we have the server and applet do get and post to one another ... I would like to do binary data exchange, but realize Base64Encoder will likely be needed. I need to be able to transvers an arbitrary byte stream without any translation .... eg: 0xF0 (byte) 0x90 (byte) 0x8c (byte) 0xB5 ... which may include nulls or anything else. If need be, I will write a converter that maps 0x00 throught 0xff to char'a' through char'z' and unpack it on each end as needed. I already have the applet and the servlet code underway and in the build directory along with the rest of my project.
You should examine the appropriate library classes, namely java.net.HttpURLConnection and related classes.
These will enable you to create GET or POST requests to a servlet and transmit text or binary data. No need to get fancy with a converter, just pay attention to the Content-type and Content-length headers.
Joined: Sep 17, 2006
Okay, so it's: I am on the network already, just use it with the java.net tools and any constraining of the applet talking to only the server it came from can be thought of in OO terms as having been done by the engineers already when I got here.
Okay, I worked on it yesterday using primarily the sources in java.net and sample servlet code. I decided to approach this with the idea that using the advice already given, the applet code can 'phone home' using name-value pairs and POST/PUT. What I need to focus on today is how Tomcat maps URI's to servlets and jsp's. For the moment, I saw HttpURLConnection is abstract, so I am sorta stuck at the moment wondering if I should use the design pattern of a utility class in the same file extending HttpURLConnection to get the benifit of having the work for PUT correctly done and already avialable. I did read that http/put can handle binary nulls and fixed block size without going through base64 encoder - that is an immediate design goal of posting the question so progress already.