You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Lemle <er...@ihc.com> on 2005/02/22 21:42:43 UTC
STRUTS PROJECT
When downloading a file how do you get the users (client) computer to
use the
print command/option instead of the open command/option.
(Maybe the the same way you get a desktop shortcut to print instead of
open when its double clicked on.)
relevant code...
private void downloadFile(String attachmentId, HttpServletResponse
response) {
Attachment attachment=Attachment.retrieve(attachmentId);
try{
BufferedOutputStream bos=new
BufferedOutputStream(response.getOutputStream());
response.setContentType(attachment.getMime_type_txt());
response.addHeader("Content-Disposition", "attachment;
filename="+attachment.getFile_nm()); //maybe something here
bos.flush();
bos.write(attachment.getFile_contents_bin());
bos.close();
}
catch(Exception e) { e.printStackTrace(); }
}
Eric D. Lemle
Senior Programmer / Analyst
Intermountain Health Care
36 South State Street, Suite 1100
Salt Lake City, Utah 84111
United States of America (USA)
(801) 442-3688 -- e-mail: Eric.Lemle@IHC.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: STRUTS PROJECT
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Do you mean you want the file to automatically print, or display the
print dialog? If so, I don't believe that's possible.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
Eric Lemle wrote:
> When downloading a file how do you get the users (client) computer to
> use the
> print command/option instead of the open command/option.
>
>
> (Maybe the the same way you get a desktop shortcut to print instead of
> open when its double clicked on.)
>
>
> relevant code...
>
>
> private void downloadFile(String attachmentId, HttpServletResponse
> response) {
>
> Attachment attachment=Attachment.retrieve(attachmentId);
> try{
> BufferedOutputStream bos=new
> BufferedOutputStream(response.getOutputStream());
> response.setContentType(attachment.getMime_type_txt());
> response.addHeader("Content-Disposition", "attachment;
> filename="+attachment.getFile_nm()); //maybe something here
> bos.flush();
> bos.write(attachment.getFile_contents_bin());
> bos.close();
> }
> catch(Exception e) { e.printStackTrace(); }
>
> }
>
>
>
>
> Eric D. Lemle
> Senior Programmer / Analyst
> Intermountain Health Care
> 36 South State Street, Suite 1100
> Salt Lake City, Utah 84111
> United States of America (USA)
> (801) 442-3688 -- e-mail: Eric.Lemle@IHC.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org