how to upload files to the server
hi all , Is it possible to upload file from the client to the server using struts. Regards, Jagan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to upload files to the server
There is an example on struts site called struts-upload. It is well commented, so try it out. If you can't find it let me know and I will email it to you directly. The file size is ~1.4M. -Original Message- From: Jagannayakam [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 6:30 AM To: Struts Users Mailing List (E-mail) Subject: how to upload files to the server hi all , Is it possible to upload file from the client to the server using struts. Regards, Jagan. - 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]
upload files
How does struts envision to send files (images, documents) to the web user back? I could not find documentation about it? Is that done in the Action class? How do I set the contents-type, such as image/gif or others and how do I set the default name that appears for the user when he is asked to save the file on his disk? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: upload files
Hi Christian, Simply use the request object passed into the Action's perform/execute method, set the content type, write whatever data is necessary, and return null (no ActionForward). -Dan- -Original Message- From: Christian Pich [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 3:54 PM To: [EMAIL PROTECTED] Subject: upload files How does struts envision to send files (images, documents) to the web user back? I could not find documentation about it? Is that done in the Action class? How do I set the contents-type, such as image/gif or others and how do I set the default name that appears for the user when he is asked to save the file on his disk? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] ** Note: By opening this email and/or any attachments contained within this file, you assume sole responsibility for any alteration of data that may occur as a consequence of any data transfer or copying process. The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. For more information on Harbor Fund's privacy policy please visit http://www.harborfund.com/privacy.htm Thank you. Harbor Capital Advisors, Inc. One SeaGate. Toledo, OH-43666. Tel: 419-247-1940 Email: [EMAIL PROTECTED] ** -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: upload files
you can set the content type from within the JSP page: response.setContentType(application/vnd.ms-excel) for the file name: response.setHeader(Content-Disposition,attachment; filename=myfile.xls;) Dmitri -Original Message- From: Christian Pich [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 3:54 PM To: [EMAIL PROTECTED] Subject: upload files How does struts envision to send files (images, documents) to the web user back? I could not find documentation about it? Is that done in the Action class? How do I set the contents-type, such as image/gif or others and how do I set the default name that appears for the user when he is asked to save the file on his disk? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: upload files
Well, I did that before without the struts framework and ran into problems: I am working in frames so when I try to output specific contents then it always defaults the contents to the frame source file contents. Also, it would not allow me to set the default file name correctly. Can I do it from an action class? Bichiko, Dmitri wrote: you can set the content type from within the JSP page: response.setContentType(application/vnd.ms-excel) for the file name: response.setHeader(Content-Disposition,attachment; filename=myfile.xls;) Dmitri -Original Message- From: Christian Pich [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 3:54 PM To: [EMAIL PROTECTED] Subject: upload files How does struts envision to send files (images, documents) to the web user back? I could not find documentation about it? Is that done in the Action class? How do I set the contents-type, such as image/gif or others and how do I set the default name that appears for the user when he is asked to save the file on his disk? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: upload files
Hi, Sort of off-topic, anyway this is the not so elegant approach that I used... response.setContentType(CONTENT_TYPE); response.setHeader(Content-Disposition, attachment; filename=\ + filename + \); ServletOutputStream out = response.getOutputStream(); byte[] inBytes = new byte[DEFAULT_BUFFER_SIZE]; FileInputStream fileInputstream = new FileInputStream(file); int len = fileInputstream.read(inBytes); while(len != -1) // Check for EOF { out.write(inBytes, 0, len); len = fileInputstream.read(inBytes); } This should give you a pop up message box asking to Save, Open, etc. Instead of 'attachment' you can also use 'inline'. Regards, Daniel -Original Message- From: Christian Pich [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 30, 2002 4:26 AM To: Struts Users Mailing List Subject: Re: upload files Well, I did that before without the struts framework and ran into problems: I am working in frames so when I try to output specific contents then it always defaults the contents to the frame source file contents. Also, it would not allow me to set the default file name correctly. Can I do it from an action class? Bichiko, Dmitri wrote: you can set the content type from within the JSP page: response.setContentType(application/vnd.ms-excel) for the file name: response.setHeader(Content-Disposition,attachment; filename=myfile.xls;) Dmitri -Original Message- From: Christian Pich [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 3:54 PM To: [EMAIL PROTECTED] Subject: upload files How does struts envision to send files (images, documents) to the web user back? I could not find documentation about it? Is that done in the Action class? How do I set the contents-type, such as image/gif or others and how do I set the default name that appears for the user when he is asked to save the file on his disk? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]