Remote Print Java Applet

I am trying to write an applet to run on jboss so the client can access it and print out the barcode label through client zebra printer connected to client parallel port. Below are my source code for the applet. However I won't be able to print the label out from the client machine at all. I try to change the policy file at the client machine and sign the applet and I able to make it print once then can't print it anymore. Any help would be welcome. Thanks.

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

import javax.print.*;

import javax.print.attribute.*;

import javax.print.attribute.standard.*;

import javax.print.event.*;

publicclass TestWriteextends JApplet

implements ActionListener

{

JTextArea ta =new JTextArea();

publicvoid init(){

JButton button =new JButton("Test Write");

button.addActionListener(this );

JPanel p =new JPanel();

p.add( button );

getContentPane().add("North", p );

getContentPane().add("Center",new JScrollPane(ta) );

}

publicvoid actionPerformed( ActionEvent e )

{

try{

String fname ="." + File.separator +"testwrite.xxx";

write("Attempting to write file: "+fname);

FileOutputStream file =new FileOutputStream( fname );

new PrintStream( file ).println("^XA^IA3^XZ^XA^LH0,3^XZ");

new PrintStream( file ).println("^XA^FWR");

new PrintStream( file ).println("^FX3.00^FS^LL1200^FS^XZ");

new PrintStream( file ).println("~DGLOGO2,00680,004,H01JF8H01JF8H01JF8H01JF8H018L018L018L018L018L018L018L0");

new PrintStream( file ).println("18L018J0F818J08018J08018J08018J08U0F8T07M0H807HFH0H80IFH0A81CJ0E818L038L");

new PrintStream( file ).println("03K0F83K0203K0203K0F83M038L01CK081IFH0F80IFI0807HFhX0F8L0281IFH0281IFI08");

new PrintStream( file ).println("I0FL01EH0F8H038H028H07I028H0EI05H01CI08H038L01CI07I0FI0H8H038H0H8H01CH0H");

new PrintStream( file ).println("8I0FH0701IFJ01IFP0F8L01M02M01M0F8gR01IFJ01IFJ01IFH09M0A8L0A8L048gH0F8V01");

new PrintStream( file ).println("IFH0F81IFH08018J08018J08018L018J0F818L018J07018J0H818J0H818J0H818J0H818g");

new PrintStream( file ).println("07M0H8L0H8L0H8L07O01IFJ01IFH0F81863H0101863H0201863H0F81863J01863J01863J");

new PrintStream( file ).println("01863J01803I081803H0181803H0601803H08018J06M018M08T0FM028L028L0F01IFJ01I");

new PrintStream( file ).println("FH0F81IFH0801803H0801803J01803J01803H0F81803H0801803H0801803K0C07K0E0EH0");

new PrintStream( file ).println("F807FCH0A807FCH0A801FI0H8L08N08L01M0EM01N080C1CK0E3EJ01C3FJ018H7J01863J0");

new PrintStream( file ).println("3863J03063J03063J03063J03863J01863J01CE7K0FC6K0FC6K07gS02L01EM02T01EM04M");

new PrintStream( file ).println("08M04L01EH0");

new PrintStream( file ).println("^XA^FWR");

new PrintStream( file ).println("^FT570,838^XGLOGO2.GRF,1,1^FS");

new PrintStream( file ).println("^CF0,27,25^CI1^A0,27,25^FT530,710^FDCS OPTO^FS");

new PrintStream( file ).println("********** REMARK ********** vDEVICE");

new PrintStream( file ).println("^CFA,18,10^CI1^AA,18,12^FT580,30^FDPART# :^FS");

new PrintStream( file ).println("^XZ^XA^LH0,3^XZ");

file.close();

write("Success!");

}catch ( Exception e2 ){

write("Caught Exception: " + e2 );

write("Failed to write file...");

}

try{

PrintService psZebra =null;

String sPrinterName =null;

PrintService[] services = PrintServiceLookup.lookupPrintServices(null,null);

for (int i = 0; i < services.length; i++){

PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class);

sPrinterName = ((PrinterName)attr).getValue();

if (sPrinterName.toLowerCase().indexOf("zebra") >= 0){

psZebra = services[i];

break;

}

}

if (psZebra ==null){

System.out.println("Zebra printer is not found.");

return;

}

System.out.println("Found printer: " + sPrinterName);

DocPrintJob job = psZebra.createPrintJob();

//String s = "^XA^FO5,40^BY3^B3,,30^FD123ABC^XZ"; // good

String s ="^XA^IA3^XZ^XA^LH0,3^XZ";// '\n' does not hurt

byte[] by = s.getBytes();

DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;

// MIME type = "application/octet-stream",

// print data representation class name = "[B" (byte array).

Doc doc =new SimpleDoc(by, flavor,null);

job.print(doc,null);

}catch (PrintException e3){

e3.printStackTrace();

}

}

privatevoid write( String s ){

ta.append( s +"\n" );

}

}

[8357 byte] By [vpirea] at [2007-11-27 1:08:47]
# 1
Hi, can't you resolv problem? I have the same problem, please you can help me.
poppetmastera at 2007-7-11 23:44:03 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...