9.3.4  Streaming and viewing a RTF document from a www server 
Postscript files can be tricky. The easier method is to create a RTF file instead of a Postscript one. In 
addition, RTF files can be loaded directly into a word processor for further editing. 
The following JSP listing does the same thing as the listing in chapter 9.3.2, except the form file is assumed 
to be in RTF format. 
<% 
  response.reset(); 
  response.setContentType("application/rtf"); 
  response.setHeader("Content Disposition","inline; filename=form.rtf"); 
/* Read the RTF file into a buffer */ 
  java.io.FileReader _reader = new 
java.io.FileReader(application.getRealPath("form.rtf")); 
  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); 
  } 
/* Use an utility function to insert the live values */ 
  xfij.util.FormUtil.format(buffer, 
   new String[] { "LABTEST", "NAME", "INUSE","DATE","PERSON","LENGTH"}, 
   new String[] { laboratoriotutkimusBean.getAbbreviation(), 
laboratoriotutkimusBean.getName() 
    , laboratoriotutkimusBean.getInuse(), laboratoriotutkimusBean.getDate() 
    , laboratoriotutkimusBean.getPerson(), 
laboratoriotutkimusBean.getLength()}); 
/* 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(); 
%> 
37 






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