You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by maven apache <ap...@gmail.com> on 2010/12/27 12:26:16 UTC

change the filename to be downloaded

Hi:
In myapplication,I have to generate a ms-word file(I use the apache poi).
1)first I save the generated file to disk.
2)set the inputstream according to the file.Of course,the action result type
is already set to stream.

here is a exmapleI found about file downing:
http://www.mkyong.com/struts2/struts-2-download-file-example/

Now,my problem is how to set the filename? Since the filename is set in the
action in the struts.xml.

<param name="contentDisposition">attachment;filename="fileABC.txt"</param>

Is there any way can set the filename dynamicly?

BTW,is there some idea can avoid the step for storing the tmp file in the disk?

Re: change the filename to be downloaded

Posted by maven apache <ap...@gmail.com>.
2010/12/29 Dave Newton <da...@gmail.com>

> I didn't misunderstand you at all; now you're asking a different question.
>
> Have you checked that the content type is correct in the headers?
>

:)

Thanks, I will have a try.

>
> Dave
>  On Dec 28, 2010 7:18 PM, "maven apache" <ap...@gmail.com> wrote:
> > I am afraid you misundersatnd me.
> >
> > *I mean jus the "contentType"*
> >
> > Nomatter I set it to text/plain or application/vnd/ms-word,I can not see
> the
> > difference. So I wonder if there is relly no difference.
> >
> > 2010/12/29 Dave Newton <da...@gmail.com>
> >
> >> http://struts.apache.org/2.x/docs/stream-result.html
> >>
> >> On Tue, Dec 28, 2010 at 7:35 PM, maven apache <apachemaven0@gmail.com
> >> >wrote:
> >>
> >> > Hi jlmagc:
> >> >
> >> > How do you set the contenttype in the result of the action?
> >> >
> >> > 2010/12/27 maven apache <ap...@gmail.com>
> >> >
> >> > >
> >> > >
> >> > > 2010/12/27 <jl...@gmail.com>
> >> > >
> >> > >> That's right. I don't have access to the code now, but I will try
> to
> >> > send
> >> > >> it later. Check the syntax, I'm sure you will find some
> >> > >
> >> > >
> >> > > No hurry. :) Thanks.
> >> > >
> >> > >
> >> > >> examples
> >> > >> Sent via BlackBerry from T-Mobile
> >> > >>
> >> > >> -----Original Message-----
> >> > >> From: maven apache <ap...@gmail.com>
> >> > >> Date: Mon, 27 Dec 2010 20:42:15
> >> > >> To: Struts Users Mailing List<us...@struts.apache.org>
> >> > >> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> >> > >> Subject: Re: change the filename to be downloaded
> >> > >>
> >> > >> 2010/12/27 <jl...@gmail.com>
> >> > >>
> >> > >> > I do the same, but with an excel, and I'm able to write the excel
> >> > >> direclty
> >> > >> > to an input stream. I don't know about word, but I suppouse it
> would
> >> > be
> >> > >> the
> >> > >> > same. Also, I think you can set a getFileName method in the
> action,
> >> > and
> >> > >> it
> >> > >> > can be used as follows
> >> > >> >
> >> > >> >
> >> > >> write the excel direclty to an input stream
> >> > >>
> >> > >> ? How,the wirte method write(OutputStream out),isn't it?
> >> > >>
> >> > >>
> >> > >> > <param
> >> > >> name="contentDisposition">attachment;filename="{fileName}"</param>
> >> > >> >
> >> > >> *<param
> >> > >> name="contentDisposition">attachment;filename="{fileName}"</param>*
> >> > >>
> >> > >> My god. It can be used in this way? I do not know before. Thanks.:)
> >> > >>
> >> > >> > Sent via BlackBerry from T-Mobile
> >> > >> >
> >> > >> > -----Original Message-----
> >> > >> > From: maven apache <ap...@gmail.com>
> >> > >> > Date: Mon, 27 Dec 2010 19:26:16
> >> > >> > To: Struts Users Mailing List<us...@struts.apache.org>
> >> > >> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> >> > >> > Subject: change the filename to be downloaded
> >> > >> >
> >> > >> > Hi:
> >> > >> > In myapplication,I have to generate a ms-word file(I use the
> apache
> >> > >> poi).
> >> > >> > 1)first I save the generated file to disk.
> >> > >> > 2)set the inputstream according to the file.Of course,the action
> >> > result
> >> > >> > type
> >> > >> > is already set to stream.
> >> > >> >
> >> > >> > here is a exmapleI found about file downing:
> >> > >> > http://www.mkyong.com/struts2/struts-2-download-file-example/
> >> > >> >
> >> > >> > Now,my problem is how to set the filename? Since the filename is
> set
> >> > in
> >> > >> the
> >> > >> > action in the struts.xml.
> >> > >> >
> >> > >> > <param
> >> > >> name="contentDisposition">attachment;filename="fileABC.txt"</param>
> >> > >> >
> >> > >> > Is there any way can set the filename dynamicly?
> >> > >> >
> >> > >> > BTW,is there some idea can avoid the step for storing the tmp
> file
> >> in
> >> > >> the
> >> > >> > disk?
> >> > >> >
> >> > >> >
> >> > >>
> >> > >>
> >> > >
> >> >
> >>
>

Re: change the filename to be downloaded

Posted by Dave Newton <da...@gmail.com>.
I didn't misunderstand you at all; now you're asking a different question.

Have you checked that the content type is correct in the headers?

Dave
 On Dec 28, 2010 7:18 PM, "maven apache" <ap...@gmail.com> wrote:
> I am afraid you misundersatnd me.
>
> *I mean jus the "contentType"*
>
> Nomatter I set it to text/plain or application/vnd/ms-word,I can not see
the
> difference. So I wonder if there is relly no difference.
>
> 2010/12/29 Dave Newton <da...@gmail.com>
>
>> http://struts.apache.org/2.x/docs/stream-result.html
>>
>> On Tue, Dec 28, 2010 at 7:35 PM, maven apache <apachemaven0@gmail.com
>> >wrote:
>>
>> > Hi jlmagc:
>> >
>> > How do you set the contenttype in the result of the action?
>> >
>> > 2010/12/27 maven apache <ap...@gmail.com>
>> >
>> > >
>> > >
>> > > 2010/12/27 <jl...@gmail.com>
>> > >
>> > >> That's right. I don't have access to the code now, but I will try to
>> > send
>> > >> it later. Check the syntax, I'm sure you will find some
>> > >
>> > >
>> > > No hurry. :) Thanks.
>> > >
>> > >
>> > >> examples
>> > >> Sent via BlackBerry from T-Mobile
>> > >>
>> > >> -----Original Message-----
>> > >> From: maven apache <ap...@gmail.com>
>> > >> Date: Mon, 27 Dec 2010 20:42:15
>> > >> To: Struts Users Mailing List<us...@struts.apache.org>
>> > >> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>> > >> Subject: Re: change the filename to be downloaded
>> > >>
>> > >> 2010/12/27 <jl...@gmail.com>
>> > >>
>> > >> > I do the same, but with an excel, and I'm able to write the excel
>> > >> direclty
>> > >> > to an input stream. I don't know about word, but I suppouse it
would
>> > be
>> > >> the
>> > >> > same. Also, I think you can set a getFileName method in the
action,
>> > and
>> > >> it
>> > >> > can be used as follows
>> > >> >
>> > >> >
>> > >> write the excel direclty to an input stream
>> > >>
>> > >> ? How,the wirte method write(OutputStream out),isn't it?
>> > >>
>> > >>
>> > >> > <param
>> > >> name="contentDisposition">attachment;filename="{fileName}"</param>
>> > >> >
>> > >> *<param
>> > >> name="contentDisposition">attachment;filename="{fileName}"</param>*
>> > >>
>> > >> My god. It can be used in this way? I do not know before. Thanks.:)
>> > >>
>> > >> > Sent via BlackBerry from T-Mobile
>> > >> >
>> > >> > -----Original Message-----
>> > >> > From: maven apache <ap...@gmail.com>
>> > >> > Date: Mon, 27 Dec 2010 19:26:16
>> > >> > To: Struts Users Mailing List<us...@struts.apache.org>
>> > >> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>> > >> > Subject: change the filename to be downloaded
>> > >> >
>> > >> > Hi:
>> > >> > In myapplication,I have to generate a ms-word file(I use the
apache
>> > >> poi).
>> > >> > 1)first I save the generated file to disk.
>> > >> > 2)set the inputstream according to the file.Of course,the action
>> > result
>> > >> > type
>> > >> > is already set to stream.
>> > >> >
>> > >> > here is a exmapleI found about file downing:
>> > >> > http://www.mkyong.com/struts2/struts-2-download-file-example/
>> > >> >
>> > >> > Now,my problem is how to set the filename? Since the filename is
set
>> > in
>> > >> the
>> > >> > action in the struts.xml.
>> > >> >
>> > >> > <param
>> > >> name="contentDisposition">attachment;filename="fileABC.txt"</param>
>> > >> >
>> > >> > Is there any way can set the filename dynamicly?
>> > >> >
>> > >> > BTW,is there some idea can avoid the step for storing the tmp file
>> in
>> > >> the
>> > >> > disk?
>> > >> >
>> > >> >
>> > >>
>> > >>
>> > >
>> >
>>

Re: change the filename to be downloaded

Posted by maven apache <ap...@gmail.com>.
I am afraid you misundersatnd me.

*I mean jus the "contentType"*

Nomatter I set it to text/plain or application/vnd/ms-word,I can not see the
difference. So I wonder if there is relly no difference.

2010/12/29 Dave Newton <da...@gmail.com>

> http://struts.apache.org/2.x/docs/stream-result.html
>
> On Tue, Dec 28, 2010 at 7:35 PM, maven apache <apachemaven0@gmail.com
> >wrote:
>
> > Hi jlmagc:
> >
> > How do you set the contenttype in the result of the action?
> >
> > 2010/12/27 maven apache <ap...@gmail.com>
> >
> > >
> > >
> > > 2010/12/27 <jl...@gmail.com>
> > >
> > >> That's right. I don't have access to the code now, but I will try to
> > send
> > >> it later. Check the syntax, I'm sure you will find some
> > >
> > >
> > > No hurry. :)  Thanks.
> > >
> > >
> > >> examples
> > >> Sent via BlackBerry from T-Mobile
> > >>
> > >> -----Original Message-----
> > >> From: maven apache <ap...@gmail.com>
> > >> Date: Mon, 27 Dec 2010 20:42:15
> > >> To: Struts Users Mailing List<us...@struts.apache.org>
> > >> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > >> Subject: Re: change the filename to be downloaded
> > >>
> > >> 2010/12/27 <jl...@gmail.com>
> > >>
> > >> > I do the same, but with an excel, and I'm able to write the excel
> > >> direclty
> > >> > to an input stream. I don't know about word, but I suppouse it would
> > be
> > >> the
> > >> > same. Also, I think you can set a getFileName method in the action,
> > and
> > >> it
> > >> > can be used as follows
> > >> >
> > >> >
> > >> write the excel direclty to an input stream
> > >>
> > >> ? How,the wirte method write(OutputStream out),isn't it?
> > >>
> > >>
> > >> > <param
> > >> name="contentDisposition">attachment;filename="{fileName}"</param>
> > >> >
> > >> *<param
> > >> name="contentDisposition">attachment;filename="{fileName}"</param>*
> > >>
> > >> My god. It can be used in this way?  I do not know before. Thanks.:)
> > >>
> > >> > Sent via BlackBerry from T-Mobile
> > >> >
> > >> > -----Original Message-----
> > >> > From: maven apache <ap...@gmail.com>
> > >> > Date: Mon, 27 Dec 2010 19:26:16
> > >> > To: Struts Users Mailing List<us...@struts.apache.org>
> > >> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > >> > Subject: change the filename to be downloaded
> > >> >
> > >> > Hi:
> > >> > In myapplication,I have to generate a ms-word file(I use the apache
> > >> poi).
> > >> > 1)first I save the generated file to disk.
> > >> > 2)set the inputstream according to the file.Of course,the action
> > result
> > >> > type
> > >> > is already set to stream.
> > >> >
> > >> > here is a exmapleI found about file downing:
> > >> > http://www.mkyong.com/struts2/struts-2-download-file-example/
> > >> >
> > >> > Now,my problem is how to set the filename? Since the filename is set
> > in
> > >> the
> > >> > action in the struts.xml.
> > >> >
> > >> > <param
> > >> name="contentDisposition">attachment;filename="fileABC.txt"</param>
> > >> >
> > >> > Is there any way can set the filename dynamicly?
> > >> >
> > >> > BTW,is there some idea can avoid the step for storing the tmp file
> in
> > >> the
> > >> > disk?
> > >> >
> > >> >
> > >>
> > >>
> > >
> >
>

Re: change the filename to be downloaded

Posted by Dave Newton <da...@gmail.com>.
http://struts.apache.org/2.x/docs/stream-result.html

On Tue, Dec 28, 2010 at 7:35 PM, maven apache <ap...@gmail.com>wrote:

> Hi jlmagc:
>
> How do you set the contenttype in the result of the action?
>
> 2010/12/27 maven apache <ap...@gmail.com>
>
> >
> >
> > 2010/12/27 <jl...@gmail.com>
> >
> >> That's right. I don't have access to the code now, but I will try to
> send
> >> it later. Check the syntax, I'm sure you will find some
> >
> >
> > No hurry. :)  Thanks.
> >
> >
> >> examples
> >> Sent via BlackBerry from T-Mobile
> >>
> >> -----Original Message-----
> >> From: maven apache <ap...@gmail.com>
> >> Date: Mon, 27 Dec 2010 20:42:15
> >> To: Struts Users Mailing List<us...@struts.apache.org>
> >> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> >> Subject: Re: change the filename to be downloaded
> >>
> >> 2010/12/27 <jl...@gmail.com>
> >>
> >> > I do the same, but with an excel, and I'm able to write the excel
> >> direclty
> >> > to an input stream. I don't know about word, but I suppouse it would
> be
> >> the
> >> > same. Also, I think you can set a getFileName method in the action,
> and
> >> it
> >> > can be used as follows
> >> >
> >> >
> >> write the excel direclty to an input stream
> >>
> >> ? How,the wirte method write(OutputStream out),isn't it?
> >>
> >>
> >> > <param
> >> name="contentDisposition">attachment;filename="{fileName}"</param>
> >> >
> >> *<param
> >> name="contentDisposition">attachment;filename="{fileName}"</param>*
> >>
> >> My god. It can be used in this way?  I do not know before. Thanks.:)
> >>
> >> > Sent via BlackBerry from T-Mobile
> >> >
> >> > -----Original Message-----
> >> > From: maven apache <ap...@gmail.com>
> >> > Date: Mon, 27 Dec 2010 19:26:16
> >> > To: Struts Users Mailing List<us...@struts.apache.org>
> >> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> >> > Subject: change the filename to be downloaded
> >> >
> >> > Hi:
> >> > In myapplication,I have to generate a ms-word file(I use the apache
> >> poi).
> >> > 1)first I save the generated file to disk.
> >> > 2)set the inputstream according to the file.Of course,the action
> result
> >> > type
> >> > is already set to stream.
> >> >
> >> > here is a exmapleI found about file downing:
> >> > http://www.mkyong.com/struts2/struts-2-download-file-example/
> >> >
> >> > Now,my problem is how to set the filename? Since the filename is set
> in
> >> the
> >> > action in the struts.xml.
> >> >
> >> > <param
> >> name="contentDisposition">attachment;filename="fileABC.txt"</param>
> >> >
> >> > Is there any way can set the filename dynamicly?
> >> >
> >> > BTW,is there some idea can avoid the step for storing the tmp file in
> >> the
> >> > disk?
> >> >
> >> >
> >>
> >>
> >
>

Re: change the filename to be downloaded

Posted by maven apache <ap...@gmail.com>.
Hi jlmagc:

How do you set the contenttype in the result of the action?

2010/12/27 maven apache <ap...@gmail.com>

>
>
> 2010/12/27 <jl...@gmail.com>
>
>> That's right. I don't have access to the code now, but I will try to send
>> it later. Check the syntax, I'm sure you will find some
>
>
> No hurry. :)  Thanks.
>
>
>> examples
>> Sent via BlackBerry from T-Mobile
>>
>> -----Original Message-----
>> From: maven apache <ap...@gmail.com>
>> Date: Mon, 27 Dec 2010 20:42:15
>> To: Struts Users Mailing List<us...@struts.apache.org>
>> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>> Subject: Re: change the filename to be downloaded
>>
>> 2010/12/27 <jl...@gmail.com>
>>
>> > I do the same, but with an excel, and I'm able to write the excel
>> direclty
>> > to an input stream. I don't know about word, but I suppouse it would be
>> the
>> > same. Also, I think you can set a getFileName method in the action, and
>> it
>> > can be used as follows
>> >
>> >
>> write the excel direclty to an input stream
>>
>> ? How,the wirte method write(OutputStream out),isn't it?
>>
>>
>> > <param
>> name="contentDisposition">attachment;filename="{fileName}"</param>
>> >
>> *<param
>> name="contentDisposition">attachment;filename="{fileName}"</param>*
>>
>> My god. It can be used in this way?  I do not know before. Thanks.:)
>>
>> > Sent via BlackBerry from T-Mobile
>> >
>> > -----Original Message-----
>> > From: maven apache <ap...@gmail.com>
>> > Date: Mon, 27 Dec 2010 19:26:16
>> > To: Struts Users Mailing List<us...@struts.apache.org>
>> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>> > Subject: change the filename to be downloaded
>> >
>> > Hi:
>> > In myapplication,I have to generate a ms-word file(I use the apache
>> poi).
>> > 1)first I save the generated file to disk.
>> > 2)set the inputstream according to the file.Of course,the action result
>> > type
>> > is already set to stream.
>> >
>> > here is a exmapleI found about file downing:
>> > http://www.mkyong.com/struts2/struts-2-download-file-example/
>> >
>> > Now,my problem is how to set the filename? Since the filename is set in
>> the
>> > action in the struts.xml.
>> >
>> > <param
>> name="contentDisposition">attachment;filename="fileABC.txt"</param>
>> >
>> > Is there any way can set the filename dynamicly?
>> >
>> > BTW,is there some idea can avoid the step for storing the tmp file in
>> the
>> > disk?
>> >
>> >
>>
>>
>

Re: change the filename to be downloaded

Posted by maven apache <ap...@gmail.com>.
2010/12/27 <jl...@gmail.com>

> That's right. I don't have access to the code now, but I will try to send
> it later. Check the syntax, I'm sure you will find some


No hurry. :)  Thanks.


> examples
> Sent via BlackBerry from T-Mobile
>
> -----Original Message-----
> From: maven apache <ap...@gmail.com>
> Date: Mon, 27 Dec 2010 20:42:15
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Re: change the filename to be downloaded
>
> 2010/12/27 <jl...@gmail.com>
>
> > I do the same, but with an excel, and I'm able to write the excel
> direclty
> > to an input stream. I don't know about word, but I suppouse it would be
> the
> > same. Also, I think you can set a getFileName method in the action, and
> it
> > can be used as follows
> >
> >
> write the excel direclty to an input stream
>
> ? How,the wirte method write(OutputStream out),isn't it?
>
>
> > <param name="contentDisposition">attachment;filename="{fileName}"</param>
> >
> *<param name="contentDisposition">attachment;filename="{fileName}"</param>*
>
> My god. It can be used in this way?  I do not know before. Thanks.:)
>
> > Sent via BlackBerry from T-Mobile
> >
> > -----Original Message-----
> > From: maven apache <ap...@gmail.com>
> > Date: Mon, 27 Dec 2010 19:26:16
> > To: Struts Users Mailing List<us...@struts.apache.org>
> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Subject: change the filename to be downloaded
> >
> > Hi:
> > In myapplication,I have to generate a ms-word file(I use the apache poi).
> > 1)first I save the generated file to disk.
> > 2)set the inputstream according to the file.Of course,the action result
> > type
> > is already set to stream.
> >
> > here is a exmapleI found about file downing:
> > http://www.mkyong.com/struts2/struts-2-download-file-example/
> >
> > Now,my problem is how to set the filename? Since the filename is set in
> the
> > action in the struts.xml.
> >
> > <param
> name="contentDisposition">attachment;filename="fileABC.txt"</param>
> >
> > Is there any way can set the filename dynamicly?
> >
> > BTW,is there some idea can avoid the step for storing the tmp file in the
> > disk?
> >
> >
>
>

Re: change the filename to be downloaded

Posted by jl...@gmail.com.
That's right. I don't have access to the code now, but I will try to send it later. Check the syntax, I'm sure you will find some examples
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: maven apache <ap...@gmail.com>
Date: Mon, 27 Dec 2010 20:42:15 
To: Struts Users Mailing List<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Re: change the filename to be downloaded

2010/12/27 <jl...@gmail.com>

> I do the same, but with an excel, and I'm able to write the excel direclty
> to an input stream. I don't know about word, but I suppouse it would be the
> same. Also, I think you can set a getFileName method in the action, and it
> can be used as follows
>
>
write the excel direclty to an input stream

? How,the wirte method write(OutputStream out),isn't it?


> <param name="contentDisposition">attachment;filename="{fileName}"</param>
>
*<param name="contentDisposition">attachment;filename="{fileName}"</param>*

My god. It can be used in this way?  I do not know before. Thanks.:)

> Sent via BlackBerry from T-Mobile
>
> -----Original Message-----
> From: maven apache <ap...@gmail.com>
> Date: Mon, 27 Dec 2010 19:26:16
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: change the filename to be downloaded
>
> Hi:
> In myapplication,I have to generate a ms-word file(I use the apache poi).
> 1)first I save the generated file to disk.
> 2)set the inputstream according to the file.Of course,the action result
> type
> is already set to stream.
>
> here is a exmapleI found about file downing:
> http://www.mkyong.com/struts2/struts-2-download-file-example/
>
> Now,my problem is how to set the filename? Since the filename is set in the
> action in the struts.xml.
>
> <param name="contentDisposition">attachment;filename="fileABC.txt"</param>
>
> Is there any way can set the filename dynamicly?
>
> BTW,is there some idea can avoid the step for storing the tmp file in the
> disk?
>
>


Re: change the filename to be downloaded

Posted by maven apache <ap...@gmail.com>.
2010/12/27 <jl...@gmail.com>

> I do the same, but with an excel, and I'm able to write the excel direclty
> to an input stream. I don't know about word, but I suppouse it would be the
> same. Also, I think you can set a getFileName method in the action, and it
> can be used as follows
>
>
write the excel direclty to an input stream

? How,the wirte method write(OutputStream out),isn't it?


> <param name="contentDisposition">attachment;filename="{fileName}"</param>
>
*<param name="contentDisposition">attachment;filename="{fileName}"</param>*

My god. It can be used in this way?  I do not know before. Thanks.:)

> Sent via BlackBerry from T-Mobile
>
> -----Original Message-----
> From: maven apache <ap...@gmail.com>
> Date: Mon, 27 Dec 2010 19:26:16
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: change the filename to be downloaded
>
> Hi:
> In myapplication,I have to generate a ms-word file(I use the apache poi).
> 1)first I save the generated file to disk.
> 2)set the inputstream according to the file.Of course,the action result
> type
> is already set to stream.
>
> here is a exmapleI found about file downing:
> http://www.mkyong.com/struts2/struts-2-download-file-example/
>
> Now,my problem is how to set the filename? Since the filename is set in the
> action in the struts.xml.
>
> <param name="contentDisposition">attachment;filename="fileABC.txt"</param>
>
> Is there any way can set the filename dynamicly?
>
> BTW,is there some idea can avoid the step for storing the tmp file in the
> disk?
>
>

Re: change the filename to be downloaded

Posted by jl...@gmail.com.
I do the same, but with an excel, and I'm able to write the excel direclty to an input stream. I don't know about word, but I suppouse it would be the same. Also, I think you can set a getFileName method in the action, and it can be used as follows

<param name="contentDisposition">attachment;filename="{fileName}"</param>
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: maven apache <ap...@gmail.com>
Date: Mon, 27 Dec 2010 19:26:16 
To: Struts Users Mailing List<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: change the filename to be downloaded

Hi:
In myapplication,I have to generate a ms-word file(I use the apache poi).
1)first I save the generated file to disk.
2)set the inputstream according to the file.Of course,the action result type
is already set to stream.

here is a exmapleI found about file downing:
http://www.mkyong.com/struts2/struts-2-download-file-example/

Now,my problem is how to set the filename? Since the filename is set in the
action in the struts.xml.

<param name="contentDisposition">attachment;filename="fileABC.txt"</param>

Is there any way can set the filename dynamicly?

BTW,is there some idea can avoid the step for storing the tmp file in the disk?