Hello, i want to implement file upload and download functioality in my application using struts2. I tried to use the examples from showcase and it seems to be working but they are static and i m not able to find some good example. Virtual dj 4 0 full with crack by crazy boris studios. If any body has implemented this functionality please share with me or post some good example. I have few specific question. Chief architect home designer pro 2012 home design software. Its popular best graphics utility tool comes packed with lots of improvements and features to design 3D home. We will create Struts configuration file, struts.xml, to specify the action that handles file upload with its input page and result page, and some interceptors which intercepts the HTTP request for processing file upload. In Struts 2, the file> tag is used to create a HTML file upload component to allow users select file from their local disk and upload it to the server. In this tutorial, you will create a JSP page with file upload component, s et the maximum size and allow content type of the upload file, and display the uploaded file details. Struts 2 file upload component can be used to upload mulitpart file in struts 2 application.Struts 2 utilizes in built File upload interceptor for uploading files in struts 2 application.The Struts 2 File Upload Interceptor is based on MultiPartRequestWrapper, which is automatically applied to the request if it contains the file element. When i m uploading a file what should be the path to store so that it can be downloaded also. Should it be under or anywhere it can be saved. When i am downloading a file it seems it should be under tomcat/webapp/project. That means it should be saved here only. I m not sure how will it work. If any body have done it please help. It is very urjent. Thanks in advance. Hi Sunil, To download file, the file should be present at the location where server is running because when any user will click on download button, the action present in server will be called and it will do whole processing. I have done the same thing. In my application first of all i fetched the file from database and stored it in the location where tomcat server is running and then click of download button this this file will be downloaded. Here is my code to save a file at server location:- File file=new File('abc.jpg'); file.createNewFile(); this code will automatically create the file where server is running hopefully this will help U. You don't have to use AJAX in this case. Just have your button submit the form to your Struts action, and have the action use the type. Example: In your Struts XML: attachment;filename=report.xls application/vnd.ms-excel inputStream 1024 Your action will then provide a public InputStream getInputStream() to pass along the data. I presume that whatever library you're using to generate the Excel files (?) can write the output to an arbitrary OutputStream. A quick-and-dirty way to convert that to an InputStream: // Using Workbook from Apache POI for example. Workbook wb; //. ByteArrayOutputStream bos = new ByteArrayOutputStream(); wb.write(bos); InputStream bis = new ByteArrayInputStream(bos.toByteArray()). Hello, I put follwing in my struts.xml application/vnd.ms-excel fileStream attachment;filename=report.xls 1024 Now I followed your instructions but it gives file for download with action name that is ExportReport.action instead of report.xls So what should be the reason? – Jan 23 '10 at 12:31 •.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |