title: Print on the default printer through tomcat
body: <p>I am developing an integrated Android application with a web service TomCat and laboratory (Eclipse Java EE) she arrived at a satisfactory level, performing queries, impressions on the default printer, all quiet, but as I get the service for Tomcat he does not perform printing it is as if there is no printer connected to the server.</p>
  
  <p>The code below is used to perform printing when I am providing the service directly from Eclipse.</p>
  
  <pre><code>try{
  InputStream prin = new ByteArrayInputStream(textoimp.getBytes());
  
  INPUT_STREAM docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
  
  SimpleDoc documentoTexto = new SimpleDoc(prin, docFlavor, null);
  
  PrintService impressora = PrintServiceLookup.lookupDefaultPrintService(); // pega a impressora padrao 
  
  PrintRequestAttributeSet printerAttributes = new HashPrintRequestAttributeSet();
  
  printerAttributes.add(new JobName("Impressao", null));
  
  printerAttributes.add(OrientationRequested.PORTRAIT);
  
  printerAttributes.add(MediaSizeName.ISO_A4); // informa o tipo de folha
  
  DocPrintJob printJob = ((PrintService) impressora).createPrintJob(); //the error occurs here , the printer is null
  
  try{
  
  printJob.print(documentoTexto, (PrintRequestAttributeSet)printerAttributes);//try to print
  
  }
  
  catch(PrintException e){ 
  
  e.printStackTrace();
  JOptionPane.showMessageDialog(null, "Não foi possível realizar a impressão !!", "Erro", JOptionPane.ERROR_MESSAGE); 
  
  } 
  
  prin.close(); 
  
  } 
  
  catch(Exception e){
  
  e.printStackTrace();
  return false;
  
  }
  </code></pre>
  
  <p>But when the service is running within the Tomcat it does not work, can anyone help me?</p>