home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / PHDownload.java < prev    next >
Text File  |  1998-09-13  |  1KB  |  55 lines

  1. package symantec.sourcebook.servlet;
  2. import java.io.*;
  3. import java.net.*;
  4. import javax.servlet.*;
  5. import javax.servlet.http.*;
  6.  
  7. public class PHDownload extends PHOwner
  8. {
  9.  
  10.  
  11.    Transaction t;
  12.    String name;
  13.    String orderId;
  14.    String total;
  15.    byte[] fileData;
  16.  
  17.     int    pagenumber = ESDServlet.DOWNLOAD_PAGE_NUM;
  18.  
  19.    private final static String PAGENAME = PAGEBASE + "killerapp.class";
  20.  
  21.    public PHDownload()
  22.    {
  23.    }
  24.  
  25.    public String pageName()
  26.    {
  27.         return PAGENAME;
  28.    }
  29.  
  30.  
  31.     protected void read() throws IOException
  32.     {
  33.         FileInputStream in = new FileInputStream(pageName());
  34.         fileData = new byte[in.available()];
  35.         in.read(fileData);
  36.         in.close();
  37.    }
  38.  
  39.    protected void customize(Object pageDataObject) throws IOException
  40.    {
  41.         // do nothing
  42.    }
  43.  
  44.     protected void write(HttpServletResponse response) throws IOException
  45.     {
  46.         response.setContentType("application/x-javaclass");
  47.         response.setHeader("Content-Disposition","attachment; filename=killerapp.class;");
  48.         response.setContentLength(fileData.length);
  49.         ServletOutputStream out = response.getOutputStream();
  50.         out.write(fileData);
  51.     }
  52.  
  53.  
  54.  
  55. }