Meaningless Drivel is fun!*
The moose likes JSP and the fly likes very tedious question! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "very tedious question!" Watch "very tedious question!" New topic

very tedious question!

honey singh
Ranch Hand

Joined: Apr 26, 2002
Posts: 44
Hi the gurus here. I'm caught in very helpless position and I think that only gr8 persons like u can solve this it goes
I'm making an application using jsp and apache-tomcat as the server. Now I want to download the file from the database server. For this I'm using the following code..

cmd="select con_type,f_name from transaction where id='1';
String contentType=rs.getString("con_type");//con_type is the contenttyp
String fileName=rs.getString("f_name");
cmd="select * from transaction where id='1';
and the function which is in a bean class is as follows:--
public void downloadField(ResultSet rs, String columnName, String contentType, String destFileName)
throws SQLException, IOException, ServletException
if(rs == null)
throw new IllegalArgumentException("The RecordSet cannot be null (1045).");
if(columnName == null)
throw new IllegalArgumentException("The columnName cannot be null (1050).");
if(columnName.length() == 0)
throw new IllegalArgumentException("The columnName cannot be empty (1055).");
byte b[] = rs.getBytes(columnName);
if(contentType == null)
if(contentType.length() == 0)
if(destFileName == null)
m_response.setHeader("Content-Disposition", "attachment;");
if(destFileName.length() == 0)
m_response.setHeader("Content-Disposition", "attachment;");
m_response.setHeader("Content-Disposition", "attachment; filename=".concat(String.valueOf(destFileName)));
m_response.getOutputStream().write(b, 0, b.length);
so now when I download the file then it gives me pop-up box with the default name as "Download.jsp" whereas I haven't specified any name. and if I click to open the file...then it opens word document and with alert box saying "C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\Content\45MFWD2F\Download[1].jsp
Cannot find this file.
Please verify that correct path and file Name are given."
and if I open .html file then it says that nullpointer exception
if I open .class file then it says "IllegalStateException getOutputStream() has already been called for this response!"
any help will be greatly appreciated.
honey singh
Ranch Hand

Joined: Apr 26, 2002
Posts: 44
Is the problem which I had written above related to browser..I'm using IE version 6.0
Do I need to make some changes in the mime types of the browser to display files..
thanx in advance!
I agree. Here's the link:
subject: very tedious question!
Similar Threads
Upload Download File
How to download csv file
Problem with downloading files
how to deal with the garbage data in JSP?
File download with servlets