Thanks a million, that fixed her up real good. 

BTW--We aren't really streaming directly from the DB, I get the file from
the DB and pass it to the servlet. The servlet streams it to the response
writer. So this is all in memory and goes bye-bye after I send it out to the
client.

-----Original Message-----
From: Manish Singla [mailto:[EMAIL PROTECTED]
Sent: Monday, October 27, 2003 5:38 PM
To: Struts Users Mailing List
Subject: Re: Downloading a file from a database



Set following header to set name of attached file.

  response.setHeader("Content-Disposition","attachment; filename=\"" + 
fileName + "\"");


My two cents:
Do you really want to connect to database and strean file from database.
You may store temp file and check the date of temp file with database at 
  client's request.  Although, you might have to write a thread safe 
code which writes to temp file from database.




Nicholson, Robb wrote:
> In one of our STRUTS applications, I have a screen that allows users to
> upload and download files attached to an order. I have a JSP form that
> allows the user to browse a file on their machine and upload it. Also on
the
> form is a list of the files already attached to the order, with links
beside
> each one to either view or delete the file.
> 
> When the user goes to view a file, I retrieve the file from the Oracle
> database and send it to a servlet that sets it's content type
appropriately
> and then streams the file to the response writer.
> 
> This works great when it is a file type that the browser can handle. For
> HTML, Word, Excel, JPG, etc, the browser window (Internet Explorer is our
> corporate standard) will render the file perfectly.
> 
> However, for other file types, Explorer pops up a dialog box asking if you
> want to view or save the file. When the user tries to save the file, the
> default filename in the Save dialog is "FileView.action" (from the URL)
> instead of the filename.
> > My question is this: Is there a way I can get the filename to come up
> instead? Is there a way I can accomplish this without writing temp files
on
> the server?
> 
> My initial thought was to write the temp file and generate a URL to it
> (someone on this list was doing that a few days back). But we don't want
to
> be creating a bunch of files on the server and not knowing when we could
> clean them up, so streaming it is ideal.
> 
> If it matters, we are using JBoss 3.2.2 as the app server.
> 
> Thanks in advance,
> Robb
> 


-- 
Thanks
Manish Singla
x73166


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to