Next, the form must be 
printed
 or 
saved
 into a file so that the tagged values remain. For the Postscript 
example, a generic Postscript printer driver is used. Such driver is best obtained from Adobe (
Adobe 
Universal Postscript Windows Driver
). The driver is available for several languages. The direct link for 
an English driver is: 
http://download.adobe.com/pub/adobe/printerdrivers/win/1.x/winsteng.exe
When you have created a form that is used in printing, print the form 
into a file
 using the installed Universal 
Postscript driver. The file should be placed in the same directory as your application's JSP files are. 
Sometimes the tags that are inserted in the Postscript file are 
not
 intact, so you may have to edit the 
Postscript file by hand afterwards. 
9.3.2  Streaming a Postscript form from a www server 
The easiest way is to insert live data into the Postscript form is to create a JSP file that does this. Followed 
is a JSP listing of such procedure. The listing also streams the resulting Postscript file back to the client. 
<% 
  response.reset(); 
  response.setContentType("application/postscript"); 
  response.setHeader("Content Disposition","inline; file=form.ps"); 
/* Read the PostScript file into a buffer */ 
  java.io.FileReader _reader = new 
java.io.FileReader(application.getRealPath("form.ps")); 
  java.io.BufferedReader reader = new java.io.BufferedReader(_reader); 
  java.lang.StringBuffer buffer = new java.lang.StringBuffer(); 
  int c = 0; 
  while((c = reader.read()) !=  1) { 
   buffer.append((char)c); 
  } 
/* Get the current date in a simple format. */ 
  java.text.DateFormat format = java.text.DateFormat.getDateInstance(); 
  String today = format.format(new java.util.Date(System.currentTimeMillis())); 
/* Use an utility function to insert the live values */ 
xfij.util.FormUtil.formatPS(buffer, 
   new String[] { "LABTEST", "NAME OF THE TEST", 
"INUSE","DATE","PERSON","LENGTH",  TODAY }, 
   new String[] { laboratoriotutkimusBean.getAbbreviation(), 
laboratoriotutkimusBean.getName() 
    , laboratoriotutkimusBean.getInuse(), laboratoriotutkimusBean.getDate() 
    , laboratoriotutkimusBean.getPerson(), laboratoriotutkimusBean.getLength(), 
today}); 
/* Stream the response to client browser */ 
  java.io.OutputStreamWriter writer = new 
java.io.OutputStreamWriter(response.getOutputStream()); 
  writer.write(buffer.toString()); 
  writer.flush(); 
  writer.close(); 
  reader.close(); 
  response.flushBuffer(); 
%> 
35 






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

servlets web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved