Example: Running a Java applet using proxy support

The following example shows you the steps to run a Java™ applet using proxy support.

  1. Choose a machine to act as the proxy server. Applets can initiate network connections only to the machine from which they were originally downloaded; therefore, it works best to run the proxy server on the same machine as the HTTP server. The Java environment and CLASSPATH on the proxy server machine includes the jt400.jar file.
  2. Start the proxy server on this machine by typing: java com.ibm.as400.access.ProxyServer -verbose Specifying verbose will allow you to monitor when the client connects and disconnects.
  3. Applet code needs to be downloaded before it runs so it is best to reduce the size of the code as much as possible. The AS400ToolboxJarMaker can reduce the jt400Proxy.jar significantly by including only the code for the components that your applet uses. For instance, if an applet uses only JDBC, reduce the jt400Proxy.jar file to include the minimal amount of code by running the following command:
         java utilities.AS400ToolboxJarMaker -source jt400Proxy.jar -destination jt400ProxySmall.jar
                                             -component JDBC
  4. The applet must set the value of the com.ibm.as400.access.AS400.proxyServer system property to be the name of your proxy server. A convenient way to do this for applets is using a compiled Properties class (Example). Compile this class and place the generated Properties.class file in the com/ibm/as400/access directory (the same path your html file is coming from). For example, if the html file is /mystuff/HelloWorld.html, then Properties.class is in /mystuff/com/ibm/as400/access.
  5. Put the jt400ProxySmall.jar in the same directory as the html file (/mystuff/ in step 4).
  6. Refer to the applet like this in your HTML file:
         <APPLET archive="jt400Proxy.jar, Properties.class" code="YourApplet.class"
                 width=300 height=100> </APPLET>