hello all,
Currently i am working with GWT. I need to convert the uploaded file into byte array using Servlet . i have done that coding, when i run the code in loacal machine i am getting the request type as HttpServletRequest. when i run the code using JBoss 4.2 i am getting the request type as RequestFacade. if i pass this request to the below Method i am getting the null value. upload.parseRequest(request); And Here's my Servlet File: public class FileUploadServlet extends HttpServlet { public class FileUploadServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 5482834513987308511L; private String encoding = "UTF-8"; HttpServletRequest httpServletRequest; // public final static org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(ClosingCommentsDAOImpl.class); public FileUploadServlet() { super(); } @Override public void init(ServletConfig config) throws ServletException { super.init(config); String initParameterEncoding = config.getInitParameter("encoding"); if (initParameterEncoding != null) { setEncoding(initParameterEncoding); } } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { this.httpServletRequest = request; uploadFile(httpServletRequest); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void setEncoding(String encoding) { this.encoding = encoding; } @SuppressWarnings("rawtypes") private void uploadFile(HttpServletRequest request) throws ServletException, IOException, Exception{ FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Parse the request List items = upload.parseRequest(request); // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); //handling a normal form-field if(item.isFormField()) { System.out.println("Got a form field"); String name = item.getFieldName(); String value = item.getString(); System.out.print("Name:"+name+",Value:"+value); } else {//handling file loads System.out.println("Not form field"); String fieldName = item.getFieldName(); String fileName = item.getName(); if (fileName != null) { fileName = FilenameUtils.getName(fileName); } String contentType = item.getContentType(); boolean isInMemory = item.isInMemory(); long sizeInBytes = item.getSize(); System.out.print("Field Name:"+fieldName +",File Name:"+fileName); System.out.print("Content Type:"+contentType +",Is In Memory:"+isInMemory+",Size:"+sizeInBytes); byte[] data = item.get(); fileName = getServletContext() .getRealPath(fileName); System.out.print("File name:" +fileName); //convert array of bytes into file FileOutputStream fileOuputStream = new FileOutputStream(fileName); fileOuputStream.write(data); fileOuputStream.close(); System.out.println("Done"); } } } Any one help me to find the solution. Regards, Kesavan g. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.