Struts 1 return stream (documents)
Hello, I started struts by learning struts2. However, now i am working with struts 1: ( I am faced with a problem where user downloads a file. I have this in the struts.xml And then in the action I have this which is returning a bytestream protected class ByteArrayStreamInfo implements StreamInfo { protected String contentType; protected byte[] bytes; public ByteArrayStreamInfo(String contentType, byte[] bytes) { this.contentType = contentType; this.bytes = bytes; } public String getContentType() { return contentType; } public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(bytes); } } But when user clicks a link is sees a open close cancel dialog box...he just sees .do as file name. I know I am not returning the file name (I can) but where will I catch it?? like in struts 2...shouldnt tehre be more in the action of this? like specifying what is returned? and if i return the name.should I just make public String getFileName() method in ByteArrayStreamInfo class? Thanks! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1 return stream (documents)
Does this help? http://wiki.apache.org/struts/StrutsFileDownload Dave --- bhaarat Sharma <[EMAIL PROTECTED]> wrote: > Hello, > > I started struts by learning struts2. However, now i am working with > struts 1: ( > > I am faced with a problem where user downloads a file. > > I have this in the struts.xml > > > type="org.something1.something2.actions.download.ModificationDocumentDownloadAction" > scope="request" input="viewAwardModification"> > > > And then in the action I have this which is returning a bytestream > > protected class ByteArrayStreamInfo implements StreamInfo { > > protected String contentType; > > protected byte[] bytes; > > public ByteArrayStreamInfo(String contentType, byte[] bytes) { > this.contentType = contentType; > this.bytes = bytes; > } > > public String getContentType() { > return contentType; > } > > public InputStream getInputStream() throws IOException { > return new ByteArrayInputStream(bytes); > } > > } > > But when user clicks a link is sees a open close cancel dialog > box...he just sees .do as file name. I know I am not > returning the file name (I can) but where will I catch it?? like in > struts 2...shouldnt tehre be more in the action of this? like > specifying what is returned? and if i return the name.should I > just make public String getFileName() method in ByteArrayStreamInfo > class? > > Thanks! > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1 return stream (documents)
yes, that worked! Thanks! I remember you helped me with similar problem in S2 as well On Mon, Mar 17, 2008 at 10:07 PM, Dave Newton <[EMAIL PROTECTED]> wrote: > Does this help? > > http://wiki.apache.org/struts/StrutsFileDownload > > Dave > > > > --- bhaarat Sharma <[EMAIL PROTECTED]> wrote: > > > Hello, > > > > I started struts by learning struts2. However, now i am working with > > struts 1: ( > > > > I am faced with a problem where user downloads a file. > > > > I have this in the struts.xml > > > > > > > > > type="org.something1.something2.actions.download.ModificationDocumentDownloadAction" > > scope="request" input="viewAwardModification"> > > > > > > And then in the action I have this which is returning a bytestream > > > > protected class ByteArrayStreamInfo implements StreamInfo { > > > > protected String contentType; > > > > protected byte[] bytes; > > > > public ByteArrayStreamInfo(String contentType, byte[] bytes) > { > > this.contentType = contentType; > > this.bytes = bytes; > > } > > > > public String getContentType() { > > return contentType; > > } > > > > public InputStream getInputStream() throws IOException { > > return new ByteArrayInputStream(bytes); > > } > > > > } > > > > But when user clicks a link is sees a open close cancel dialog > > box...he just sees .do as file name. I know I am not > > returning the file name (I can) but where will I catch it?? like in > > struts 2...shouldnt tehre be more in the action of this? like > > specifying what is returned? and if i return the name.should I > > just make public String getFileName() method in ByteArrayStreamInfo > > class? > > > > Thanks! > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1 return stream (documents)
--- bhaarat Sharma <[EMAIL PROTECTED]> wrote: > Thanks! I remember you helped me with similar problem in S2 as well I'm very good at using the work of others to make me look good ;) Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1 return stream (documents)
Quick question in all other examples on that page they show how the fileName is retrieved. But for Byte Array Example they do not mention anything regarding the fileName. How are we suppose to supply the fileName? On Mon, Mar 17, 2008 at 10:41 PM, Dave Newton <[EMAIL PROTECTED]> wrote: > --- bhaarat Sharma <[EMAIL PROTECTED]> wrote: > > > Thanks! I remember you helped me with similar problem in S2 as well > > I'm very good at using the work of others to make me look good ;) > > Dave > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1 return stream (documents)
The techniques shown in the earlier examples would work equally well in the byte stream example. How you determine the source of the data to send back to the browser is really up to you. - configure it statically in struts-config.xml (as per the first two exxamples - take it from a request parameter - derive it from some other user or request data L. bhaarat Sharma wrote: Quick question in all other examples on that page they show how the fileName is retrieved. But for Byte Array Example they do not mention anything regarding the fileName. How are we suppose to supply the fileName? On Mon, Mar 17, 2008 at 10:41 PM, Dave Newton <[EMAIL PROTECTED]> wrote: --- bhaarat Sharma <[EMAIL PROTECTED]> wrote: Thanks! I remember you helped me with similar problem in S2 as well I'm very good at using the work of others to make me look good ;) Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Re: Struts 1 return stream (documents)
Forgive me if I am on the wrong track here, I think I picked up this thread in the middle... but I think I would answer: > How are we suppose to supply the fileName? By setting a response header: response.setHeader("Content-Disposition", "inline;filename="foo.xyz"); MG -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Tuesday, March 18, 2008 9:48 AM To: user@struts.apache.org Subject: Re: Struts 1 return stream (documents) The techniques shown in the earlier examples would work equally well in the byte stream example. How you determine the source of the data to send back to the browser is really up to you. - configure it statically in struts-config.xml (as per the first two exxamples - take it from a request parameter - derive it from some other user or request data L. bhaarat Sharma wrote: > Quick question > > in all other examples on that page they show how the fileName is > retrieved. But for Byte Array Example they do not mention anything > regarding the fileName. > > How are we suppose to supply the fileName? > > > On Mon, Mar 17, 2008 at 10:41 PM, Dave Newton <[EMAIL PROTECTED]> wrote: >> --- bhaarat Sharma <[EMAIL PROTECTED]> wrote: >> >>> Thanks! I remember you helped me with similar problem in S2 as well >> I'm very good at using the work of others to make me look good ;) >> >> Dave >> >> >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]