The HostPrintTerminal bean provides host print session support. This bean requires the Host On-Demand Toolkit to compile and run. See Building Host Access Beans Applets for more information on the packages to import.
The following explains each statement or group of statements used in this sample program:
import com.ibm.eNetwork.beans.HOD.*; // Get the Host Access Beans import com.ibm.eNetwork.ECL.*; // Get the ECL classes import java.applet.*; // Get the Applet class
public class Simple3270Print extends Applet {
HostPrintTerminal pTerminal = new HostPrintTerminal();
public void init() { setSize(450,450);
try { pTerminal.setSessionType(ECLHostPrintSession.SESSION_TYPE_3270_PRT_STR);
pTerminal.setHost("myHost"); pTerminal.setAutoReconnect(true);
In this statement, you need to replace "myHost" with the name of your telnet server.
pTerminal.startCommunication(); } catch (Exception e){ System.out.println("Exception =" + e); } add(pTerminal); } }
Here is the whole program, without the editorial comments:
/* A Simple3270Print Example */ import java.applet.*; import com.ibm.eNetwork.beans.HOD.*; import com.ibm.eNetwork.ECL.*; public class Simple3270Print extends Applet { // Build a HostPrintTerminal bean HostPrintTerminal pTerminal = new HostPrintTerminal(); public void init() { setSize(450,450); try { pTerminal.setSessionType(ECLHostPrintSession.SESSION_TYPE_3270_PRT_STR); // Instead of "myHost", enter the name of your telnet server pTerminal.setHost("myHost"); pTerminal.setAutoReconnect(true); pTerminal.startCommunication(); } catch (Exception e) { System.out.println("Exception =" + e); } add(pTerminal); } }
Finally, here's a simple HTML file to run the applet you created:
<HTML> <HEAD> <TITLE>First Host Print Bean Applet</TITLE> </HEAD> <BODY> <APPLET CODE="Simple3270Print.class" WIDTH=600 HEIGHT=700> </APPLET> </BODY> </HTML>
To run Simple3270Print, save the sample program in a file called Simple3270Print.java and compile it. Ensure that your CLASSPATH environment variable is set correctly (see Building Host Access Beans Applets). You can run the Simple3270Print applet by executing the following command:
appletviewer Simple3270Print.html
[ Top of Page | Previous Page | Next Page | Table of Contents ]