Results 1 to 4 of 4
- 02-23-2012, 02:22 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 6
- Rep Power
- 0
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?
- 02-23-2012, 02:47 PM #2
Member
- Join Date
- Aug 2010
- Posts
- 6
- Rep Power
- 0
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.
- 02-23-2012, 03:06 PM #3
Re: No data after downloading pdf BLOB from Oracle db
Crossposted: 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!
- 02-23-2012, 03:06 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
loading blob data in database
By newbie123 in forum JDBCReplies: 5Last Post: 12-21-2011, 03:50 PM -
How to Insert data in oracle from Ms access
By JAVA0282 in forum JDBCReplies: 3Last Post: 04-29-2010, 09:58 AM -
oracle data insertion
By mudit222 in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 04-12-2010, 06:01 PM -
Retrieving image stored as BLOB object in oracle
By venkateshcoolmoon in forum JDBCReplies: 11Last Post: 01-17-2010, 06:06 PM -
Problems updating blob columns on Oracle 9
By ljustiniano in forum JDBCReplies: 0Last Post: 08-14-2007, 06:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks