You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Felipe Schnack <fe...@ritterdosreis.br> on 2003/01/14 11:37:41 UTC

file name

  I have a servlet that generates pdf files on the fly
  but when the browser opens the "save as..." dialog, the suggested
default filename is my servlet's URL... I would like it to suggest
another file name, how can i do that?

-- 

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter@ritterdosreis.br
Fone/Fax.: (51)32303341


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: file name

Posted by Felipe Schnack <fe...@ritterdosreis.br>.
  Thank you all for the quick response, I got it working :-)
On Tue, 2003-01-14 at 12:04, Cédric Viaud wrote:
> You have to generate a specific HTTP header for this.
> 
> Do something like :
> 
> response.setHeader("Content-Disposition","attachment;
> filename="+nameOfTheFile);
> 
> I got this tip few days ago on this list.
> 
> Regards,
> 
>    Cédric
> 
> ----- Original Message -----
> From: "Felipe Schnack" <fe...@ritterdosreis.br>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Tuesday, January 14, 2003 11:37 AM
> Subject: file name
> 
> 
> >   I have a servlet that generates pdf files on the fly
> >   but when the browser opens the "save as..." dialog, the suggested
> > default filename is my servlet's URL... I would like it to suggest
> > another file name, how can i do that?
> >
> > --
> >
> > Felipe Schnack
> > Analista de Sistemas
> > felipes@ritterdosreis.br
> > Cel.: (51)91287530
> > Linux Counter #281893
> >
> > Centro Universitário Ritter dos Reis
> > http://www.ritterdosreis.br
> > ritter@ritterdosreis.br
> > Fone/Fax.: (51)32303341
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
-- 

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter@ritterdosreis.br
Fone/Fax.: (51)32303341


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: file name

Posted by C�dric Viaud <ce...@matrasi-tls.fr>.
You have to generate a specific HTTP header for this.

Do something like :

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

I got this tip few days ago on this list.

Regards,

   Cédric

----- Original Message -----
From: "Felipe Schnack" <fe...@ritterdosreis.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, January 14, 2003 11:37 AM
Subject: file name


>   I have a servlet that generates pdf files on the fly
>   but when the browser opens the "save as..." dialog, the suggested
> default filename is my servlet's URL... I would like it to suggest
> another file name, how can i do that?
>
> --
>
> Felipe Schnack
> Analista de Sistemas
> felipes@ritterdosreis.br
> Cel.: (51)91287530
> Linux Counter #281893
>
> Centro Universitário Ritter dos Reis
> http://www.ritterdosreis.br
> ritter@ritterdosreis.br
> Fone/Fax.: (51)32303341
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: file name

Posted by Andoni <an...@indigo.ie>.
response.setHeader("Content-Disposition"," attachment;
filename=SuggestedFileName.pdf");


----- Original Message -----
From: "Felipe Schnack" <fe...@ritterdosreis.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, January 14, 2003 10:37 AM
Subject: file name


  I have a servlet that generates pdf files on the fly
  but when the browser opens the "save as..." dialog, the suggested
default filename is my servlet's URL... I would like it to suggest
another file name, how can i do that?

--

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter@ritterdosreis.br
Fone/Fax.: (51)32303341


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


AW: file name

Posted by Holger Klein-Altstedde <ho...@prioeins.de>.
Try something like this (response.setHeader):

[snip]

 String savepath=DLBean.getSavePath();

 savepath+=exp+"_"+sub+"/";

 if(DLBean.getDownloadByKey(dow))
 {
  if(DLBean.getNextDownload())
    {
     String file = DLBean.getColumn("file");
     String saveasfile = DLBean.getColumn("saveasname");
     String origfile = DLBean.getColumn("origfilename");
     String mimetype = DLBean.getColumn("mimetype");

	//read the file name.
        savepath+=file;
	File f = new File (savepath);
        
	//set the content type(can be excel/word/powerpoint etc..)
	response.setContentType (mimetype);
	//set the header and also the Name by which user will be
prompted to save
        if(!saveasfile.equals(""))
    	  response.setHeader ("Content-Disposition", "attachment;
filename=\""+saveasfile+"\"");
        else
	  response.setHeader ("Content-Disposition", "attachment;
filename=\""+origfile+"\"");

        response.setHeader("Content-Length",(new
Long(f.length())).toString() );

 	InputStream in = new FileInputStream(f);
        ServletOutputStream outs = response.getOutputStream();

        int bit = 256;
	int i = 0;

	try 
        {
    	    while ((bit) >= 0) 
            {
        	bit = in.read();
        	outs.write(bit);
            }
        } 
        catch (IOException ioe) 
        {
            ioe.printStackTrace(System.out);
        }
        outs.flush();
        outs.close();
        in.close();
  }
 }
[snip]

Hope this helps.


> -----Ursprüngliche Nachricht-----
> Von: Felipe Schnack [mailto:felipes@ritterdosreis.br] 
> Gesendet: Dienstag, 14. Januar 2003 11:38
> An: Tomcat Users List
> Betreff: file name
> 
> 
>   I have a servlet that generates pdf files on the fly
>   but when the browser opens the "save as..." dialog, the suggested
> default filename is my servlet's URL... I would like it to suggest
> another file name, how can i do that?
> 
> -- 
> 
> Felipe Schnack
> Analista de Sistemas
> felipes@ritterdosreis.br
> Cel.: (51)91287530
> Linux Counter #281893
> 
> Centro Universitário Ritter dos Reis
> http://www.ritterdosreis.br
> ritter@ritterdosreis.br
> Fone/Fax.: (51)32303341
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:tomcat-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>