I just finished trudging through this very same issue.  Below is the code
snippet I use to actually send the .pdf file (your step 4).  I still haven't
figured out when to use the "Accept-ranges" header (ignore the fact that I'm
using it if the file is greater than 30,000 bytes -- this is just a guess on my
part).

Details on how to implement byteserving for Adobe can be found at:

http://www.adobe.com/support/techguides/acrobat/byteserv/byteserv03.html

The other steps should be a piece of cake, and can be handled well by servlets
(my download servlet performs most of the functions you list).

Good luck.

key  =  filename

    StringBuffer url = HttpUtils.getRequestURL(req);
    String urlDisplay = url.toString();

// I retrieve complete path to file "PATH" and the ContentType
//
      path = rs.getString("FILE_PATH");
      contentType = rs.getString("FILE_CONTENTTYPE");
      hostpath = rs.getString("FILE_HOSTPATH");

//
// I run this servlet on several machines, so this checks to make sure that the
file is
// on this particular machine -- if not, the servlet let's the user know what
machine it
// is on.

      if (urlDisplay.equals(hostpath)) {

                        ServletOutputStream os;
//                        OutputStream os;
                        os = res.getOutputStream();
                        FileInputStream theFile = new FileInputStream( path);
      int fileSize = theFile.available();
//
// v. 2.2 Implementation
//
//      res.setBufferSize(4096);

      if (fileSize > 30000) {
       res.setHeader("Accept-Ranges", "bytes");
      }
                        res.setContentType(contentType);
         res.setHeader("Content-Disposition", key);
      res.setContentLength(fileSize);
//
// v. 2.2 Implementation
//      res.flushBuffer();

                        int i;
                        byte b[] = new byte[ 1024];
//                        byte b[] = new byte[ 4096];
                        while(( i = theFile.read( b))>0) {
                         os.write( b, 0, i);
//
// v. 2.2 Implementation
//       res.flushBuffer();
         os.flush();
      }
                        theFile.close();
                        os.close();


Niranjan Soni wrote:

> Hi All
>
> I want to download PDF files which are at the server,
> at client machine. The process goes something like
> this.
> 1. The client Logs in and is validated from the
> database.
> 2. Depending upon the Clients identity, the client is
> shown separate folders which shows the list of PDF
> Files that can be downloaded.
> 3. The Client can then select one or more PDF files
> that he/she wants to download.
> 4. The download of the files is initiated to Client
> machine, in the directory specified by him.
> 5. In the end, the userID and files downloaded by him
> are logged in a journel or log file in the database on
> the server.
>
> This process is to run on AS400 server. I am thinking
> of using Servlets to handle this functionality. Can
> this be achieved using Servlets? If yes then how this
> can be achieved?
>
> What other possible approaches can be used. and how
> this can be achieved.
>
> If u guys point to me right direction, i would
> appricate ur help. If there is documentation or some
> help available on this, please tell me about it.
>
> Thanks
> Niranjan
> [EMAIL PROTECTED]
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
Ron Parker
Software Creations            http://www.scbbs.com
TradeWinds Publishing         http://www.intl-trade.com
TradePoint Los Angeles        http://www.tradepointla.org
SiteDirector Security Server  http://livepublish.scbbs.com
Civil War Online Library      http://civilwar.scbbs.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to