Sorry im new in this forum. The printer is a usb thermal printer EC 5890X. Let me explain better. I think that the problem is something between tomcat and the war file becouse when i ran the application in the same version of tomcat (tomcat 7) the application prints the ticket, but when the war file is loaded in tomcat the ticket does not print and there werent any error or message that reveals a issue.
My code for print is:
i crated the ticket in an array of strings, then i create a file with the array of strings (the ticket) and later i print the file in the next method:
public void imprimir(
String ticketName){
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
//use the default printer
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
if (service != null) {
try {
//create a print job
DocPrintJob job = service.createPrintJob();
//attributes of the job
DocAttributeSet das = new HashDocAttributeSet();
FileInputStream fis = new FileInputStream(ticket+".txt");
Doc doc = new SimpleDoc(fis,flavor,das);
try {
//the job is send it to the printer
job.print(doc,null);
}
catch(Exception e){
e.printStackTrace();
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
I dont know if in tomcat the application has privileges to create a file maybe that is the problem.