Re: Upload file content to text box using struts 1.3.8
(1)Select file from a [file input] (2)Upload it to your Action (by a post) (3)In your action, read in the CSV data, and store into some property(let's say CSVDataProperty) (4)Show your page again, and set the default value of the textarea by CSVDataProperty 2010/11/30 Anjib Mulepati anji...@hotmail.com: Can anyone help me on getting file content (txt/CSV file) to be load in text area of web page? I have textarea in webpage and want to load the content of the file to that textarea. I am using struts 1.3.8. I couldn't fig out how can mimic file input button. Any hint will be appreciated. Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file content to text box using struts 1.3.8
This textarea itself is one of the component of the form. So how to put two forms in a single page? On 11/29/2010 9:30 PM, Li Ying wrote: (1)Select file from a [file input] (2)Upload it to your Action (by a post) (3)In your action, read in the CSV data, and store into some property(let's say CSVDataProperty) (4)Show your page again, and set the default value of the textarea by CSVDataProperty 2010/11/30 Anjib Mulepatianji...@hotmail.com: Can anyone help me on getting file content (txt/CSV file) to be load in text area of web page? I have textarea in webpage and want to load the content of the file to that textarea. I am using struts 1.3.8. I couldn't fig out how can mimic file input button. Any hint will be appreciated. Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file content to text box using struts 1.3.8
Why do you need two forms? Can't you put the FileUpload and the textarea in one form? And in your Action, you can create 2 method, one handle the file upload, and the other one handle the other request - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file content to text box using struts 1.3.8
Another way is, using AJAX: (1)Send a file upload post, (using AJAX), to your FileUploadAction (2)FileUploadAction just read in the CSV file content, and return it as HTTP Response (3)On client side, AJAX can receive the Server response, then you can put it to the textarea (using JQuery) See: http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file without struts 2
config the servlet-mapping. alter the URL, that some old modules url don't filtered by struts2! On Tue, Oct 7, 2008 at 11:30 AM, Po Po [EMAIL PROTECTED] wrote: Hello, Some modules in my application not yet migrate to struts 2. upload file doesn't work (using commons file upload), because it's intercept by struts 2. How to disable / avoid upload file functionality in struts 2 ? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- BestRegards, Mead http://yayisoft.com Milton Berle - If opportunity doesn't knock, build a door.
RE: Upload File
This probably won't help, but (you never know) - you might want to specify method=POST. So: html:form action=/foto enctype=multipart/form-data method=POST Just a thought. Daniel -Original Message- From: Flávio Maldonado [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 27, 2005 1:52 PM To: Struts Users Mailing List Subject: Upload File Hello I'm having a problem to upload a file using struts... I search for the error at Google... but I didn't solve my problem yet. I have this JSP: html:form action=/foto enctype=multipart/form-data tr td table cellpadding=0 cellspacing=15 width=100% tr td width=50% align=righthtml:file property=theFile size=40//td /tr tr td width=50% align=righthtml:submit value=Ok//td /tr /table /td /tr /html:form when I click in Ok button to call the action class, the servlet throws an exception: java.lang.NoSuchMethodError: org.apache.commons.fileupload.FileUpload.setSizeMax(I)V at org.apache.struts.upload.CommonsMultipartRequestHandler.handle Request(Common sMultipartRequestHandler.java:220) at org.apache.struts.util.RequestUtils.populate(RequestUtils.java :934) at I got the struts-upload.war example and it works fine... but my application didn't! I don't know what i'm doing wrong... I put the struts.jar and commons-upload.jar in the classpath I think this is a detail... but I'm not seeing what I'm doing wrong. Something can help me? Thanks. Have a happy new year. Flávio Maldonado ___ Yahoo! doce lar. Faça do Yahoo! sua homepage. http://br.yahoo.com/homepageset.html - 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: Upload File
Flávio Maldonado wrote: Hello I'm having a problem to upload a file using struts... I search for the error at Google... but I didn't solve my problem yet. I have this JSP: html:form action=/foto enctype=multipart/form-data tr td table cellpadding=0 cellspacing=15 width=100% tr td width=50% align=righthtml:file property=theFile size=40//td /tr tr td width=50% align=righthtml:submit value=Ok//td /tr /table /td /tr /html:form when I click in Ok button to call the action class, the servlet throws an exception: java.lang.NoSuchMethodError: org.apache.commons.fileupload.FileUpload.setSizeMax(I)V at org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(Common sMultipartRequestHandler.java:220) at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:934) at I got the struts-upload.war example and it works fine... but my application didn't! I don't know what i'm doing wrong... I put the struts.jar and commons-upload.jar in the classpath I think this is a detail... but I'm not seeing what I'm doing wrong. Something can help me? I'd guess you have the wrong version of commons-upload.jar deployed. Check you're using the right version, and that there isn't another version elsewhere on the classpath of either your application or your servlet container. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Upload File
I'm certainly not an upload expert, but I have succeeded in uploading files before by following the struts sample upload application. You can find this among the sample webapps included in the struts binary distribution. Check out the code in that sample app, including how the form was declared and how the action processed the file being uploaded. Hubert On Thu, 17 Mar 2005 11:53:48 -0300, Flávio Maldonado [EMAIL PROTECTED] wrote: Hi all! I'm having a problem to Upload File... This is my JSP html:form action=/upload html:file name=vibraconForm property=upFile / html:submit property=actionOk/html:submit /html:form I choose a file and when I click in Ok button, show this errors message: exception javax.servlet.ServletException: BeanUtils.populate org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1099) org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j ava:798) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.IllegalArgumentException: argument type mismatch sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) java.lang.reflect.Method.invoke(Method.java:324) org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.j ava:1789) org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.j ava:1684) org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:17 13) org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:924) org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:729) org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1097) org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j ava:798) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. What's going on? Somebody can helps me? Thanks... Atc. Flávio Vilasboas Maldonado Diretor de Desenvolvimento SedNet Soluções em TI +55 (35) 3471-9381 - 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: Upload File
You need to specify an enctype...theres a some info on uploading files here on the wiki: http://wiki.apache.org/struts/StrutsFileUpload Niall - Original Message - From: Flávio Maldonado [EMAIL PROTECTED] Sent: Thursday, March 17, 2005 2:53 PM Hi all! I'm having a problem to Upload File... This is my JSP html:form action=/upload html:file name=vibraconForm property=upFile / html:submit property=actionOk/html:submit /html:form - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Upload file size limit
One technique would be overriding dispatchactions execute method in that action to check for this attribute and then delegating back to the superclass to handle the normal situation when its not found or calling the appropriate method when it is? ie: public ActionForward execute(ActionMapping mapping, ... ) { if( request.getAttribute( MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED) != null) { return myMethod(mapping, ...) } else { return super.execute(mapping, ...); } } Diego wrote: Hi! I want to prevent the users from uploading files bigger than 1 MB, so I've put this on my struts-config: controller nocache=true inputForward=false maxFileSize=1M/ The problem is that, AFAIK, when the max file size is exceeded, the same Action which receives the file is invoked with this attribute in the request: MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED The problem is that I'm using DispatchAction on my app, and when the file size is exceeded, Struts is invoking my DispatchAction with no arguments, so I get an error. Do I have something wrong in my config or it's possible to change this behaviour? I've thought of creating a normal Action to receive file uploads, but I would want to avoid this, if possible. Thanks in advance - 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: upload file filter in struts
Hi Vijaya, Try using isFormField() method of FileItem interface, which indicates whether the item is form field or not. If it is then u can use getFieldName() and getString() on FileItem to retrieve the form field name and value of it in String format. Hope this would be helpful. For details of various API used below (http://jakarta.apache.org/commons/fileupload/apidocs/index.html) Regards, Kailash -Original Message- From: vijaya shetty [mailto:[EMAIL PROTECTED] Sent: Thursday, July 22, 2004 7:05 AM To: [EMAIL PROTECTED] Subject: upload file filter in struts Hi I have an struts application which does the authorisation in filters. Authorisation is done using the request.getParameter(menu). This filter works very fine But fails when the the request is of enctype=multipart/form-data. i.e when i am using the file upload in the page. To solve this i used the commons-fileupload to get the Parameter. Now again the parameter is available at filter, but the request fails at Action of Struts. Now how do i convert the request back to the original form. If you could get me the code, it would be highly appreciated. My parsing code: int contentLength = request.getContentLength(); // Copy the request's input stream. final ServletInputStream bis = request.getInputStream(); final BufferedOutputStream bos; final Object bodyData; if (contentLength 5) { // Use a disk file for storing the body data. bodyDataFile = File.createTempFile(body-, .data); bodyDataFile.deleteOnExit(); final FileOutputStream fos = new FileOutputStream(bodyDataFile); bos = new BufferedOutputStream(fos); bodyData = bodyDataFile; } else { // Use a byte array for storing the body data. final ByteArrayOutputStream baos = new ByteArrayOutputStream(); bos = new BufferedOutputStream(baos); bodyData = baos; } final int BUFFER_SIZE = 10240; byte[] buffer = new byte[BUFFER_SIZE]; int toBeCopied = contentLength; while (toBeCopied 0) { int read = bis.read(buffer, 0, Math.min(BUFFER_SIZE, toBeCopied)); bos.write(buffer, 0, read); toBeCopied -= read; } bis.close(); bos.close(); // Wrap the request in a FileUploadHttpServletRequest for further processing. chain.doFilter(new FileUploadHttpServletRequest((HttpServletRequest) request, bodyData), response); Thanks Vijaya Yahoo! India Careers: Over 65,000 jobs online Go to: http://yahoo.naukri.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Quinnox - Global Leadership in eBusiness and IT services, vertically aligned for clients in the automotive/discrete manufacturing, SAP , ERP , and powered by an offshore-based global delivery model. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]