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 > 50000) { // 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]