DemonstrationExample of Sending and Receiving Binary Image Data
This example demonstrates sending and receiving raw binary data. Specifically, one script sends the applet a java.gif file and a cgi.jpg image file. These files are then chosen by you, the user, for posting in raw form back to another script which creates an image file "on the fly" in a TempImage directory. This tempory image is then loaded into the Applet for display using the MediaTracker object.
The JavaCGIBridgeExtension class is used instead of the core JavaCGIBridge class since we are posting arbitrary binary data to the server. In a case such as this, typical URLEncoding form key, value pairs will not work well because the parsing is based on arbitrary symbols such as =, ?, and &. It is easier to just send the data to a CGI script that expects to receive raw binary data. To do this, JavaCGIBridgeExtension has a getByteArrayOutputStream method which allows you to write to an arbitrary byte output stream whose contents will be posted to the CGI script.
Note: If you set up this example on your own server, the CGI script will need write access to the TempImage directory.
Example Raw Binary Image Data Applet
View The Source To Example6Applet.java
View The Source To Example6DrawPanel.java
View The Source To JavaCGI Bridge.java
View The JavaCGIBridge JavaDoc File
View The Source To JavaCGIBridgeTimeOutException.java
View The JavaCGIBridgeTimeOutException JavaDoc File
View The Source To get_images.cgi
View The Source To make_image.cgi