|

January 20th, 2011, 05:19 PM
|
|
Registered User
|
|
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by lapog
I am trying to write an application which can upload and download files [Excel, Word etc.] to/from an Oracle 9i database Blob field. I am using Java/JSP for the same.
The upload part works just fine. However, when I try to download the file that I uploaded, I get an error.
A dialog box comes up asking me to Open/Save the file. However, when I try to save it, it says
âInternet Explorer cannot download â¦..tion=download&planId= testplan from localhost
Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.â
I am using IE 6.0. I tested the same with Firefox browser and was able to download the file.
Can anyone help?
Code:
Following is the code I am using for the same.
/* Code to retrieve from Blob field */
String sqlString = "SELECT PLAN_DOCUMENT_NAME,PLAN_DOCUMENT FROM BRS_PLAN_DESCRIPTION WHERE PLAN_ID = ?";
ps = con.prepareStatement(sqlString);
ps.setString (1,planId);
rs = ps.executeQuery();
while (rs.next()) {
fileBytes = rs.getBytes("PLAN_DOCUMENT");
fileName = rs.getString("PLAN_DOCUMENT_NAME");
}
brsPlanDocument.setPlanId(planId);
brsPlanDocument.setFileName(fileName);
brsPlanDocument.setFileBytes(fileBytes);
/* Code for download */
String fileName = brsPlanDocument.getFileName();
String fileType = fileName.substring(fileName.indexOf(".")+1,fileNam e.length());
if (fileType.trim().equalsIgnoreCase("txt"))
{
response.setContentType( "text/plain" );
}
else if (fileType.trim().equalsIgnoreCase("doc"))
{
response.setContentType( "application/msword" );
}
else if (fileType.trim().equalsIgnoreCase("xls"))
{
response.setContentType( "application/vnd.ms-excel" );
}
else if (fileType.trim().equalsIgnoreCase("pdf"))
{
response.setContentType( "application/pdf" );
}
else if (fileType.trim().equalsIgnoreCase("ppt"))
{
response.setContentType( "application/ppt" );
}
else
{
response.setContentType( "application/octet-stream" );
}
response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
response.setHeader("cache-control", "no-cache");
byte[] fileBytes=brsPlanDocument.getFileBytes();
ServletOutputStream outs = response.getOutputStream();
outs.write(fileBytes);
outs.flush();
outs.close();
|
Can anyone tell me what is this brsPlanDocument object ?
|