Results 1 to 4 of 4
  1. #1
    reubenmk is offline Member
    Join Date
    Aug 2010
    Posts
    6
    Rep Power
    0

    Default No data after downloading pdf BLOB from Oracle db

    Hi

    1.I want to download a pdf file which is stored in the oracle db as a blob. But i get 0 kb file.
    I havent done this before. So pls help
    on button click a servlet calls another servlet which does the job of downloading.
    This is the code i wrote to download the file.

    protected void processRequest(HttpServletRequest request, HttpServletResponse resp)
    throws ServletException, IOException {
    resp.setContentType("text/html;charset=UTF-8");
    try {
    OutputStream outStream = resp.getOutputStream();
    List file=(List)request.getAttribute("file");
    String fileName=null;
    byte[] fileBytes=null;
    for (int i=0;i<file.size();i++)
    {
    Map objec=(Map) file.get(i);
    fileName=(String)objec.get("fileName");
    fileBytes=(byte[])objec.get("fileBytes");
    }
    String fileType = fileName.substring(fileName.indexOf(".")+1,fileNam e.length());
    if (fileType.trim().equalsIgnoreCase("pdf"))
    {
    resp.setContentType( "application/pdf" );
    }

    resp.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
    resp.setHeader("cache-control", "must-revalidate");
    System.out.println(fileBytes);
    } finally {
    // out.close();
    }
    }


    Please tell me where i went wrong.How can i download the full pdf file with data?

    2. Lets say this pdf file is a full report of customer details.lets assume its got 300 pages. and for each customer the page no's are known. ex for customer Antony his page no in this pdf is 4 and 5. I want to only download the file with these 2 pages.How can i accomplish this task?

  2. #2
    reubenmk is offline Member
    Join Date
    Aug 2010
    Posts
    6
    Rep Power
    0

    Default Re: No data after downloading pdf BLOB from Oracle db

    UPDATE:I solved my first problem which was very silly...just had to add the following lines

    resp.getOutputStream().write(fileBytes);
    resp.getOutputStream().flush();
    resp.getOutputStream().close();

    So i finally succeeded with that. Now pls some1 help me for my second problem.I want to download pages for which page no's are known from the pdf and save as a separate pdf file. Actually thats the pdf i want to download. Not the first pdf. I just did that to learn to download a blob file.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default Re: No data after downloading pdf BLOB from Oracle db

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: No data after downloading pdf BLOB from Oracle db

    Are you asking how to break up a PDF by page then?
    There are several PDF manipulation libraries out there, PDFBox and iText come to mind.
    I have no idea how successfully they would do what you need.

Similar Threads

  1. loading blob data in database
    By newbie123 in forum JDBC
    Replies: 5
    Last Post: 12-21-2011, 03:50 PM
  2. Replies: 3
    Last Post: 04-29-2010, 09:58 AM
  3. oracle data insertion
    By mudit222 in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 04-12-2010, 06:01 PM
  4. Retrieving image stored as BLOB object in oracle
    By venkateshcoolmoon in forum JDBC
    Replies: 11
    Last Post: 01-17-2010, 06:06 PM
  5. Problems updating blob columns on Oracle 9
    By ljustiniano in forum JDBC
    Replies: 0
    Last Post: 08-14-2007, 06:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •