as a first step, I'd recommend to check what is actually
sent to the server.
you could use e.g. firebug (a firefox plugin)

then you will at leas know if the problem is on your client
code or on your server code

On 17 Feb., 15:59, Ravi <raveend...@yahoo.com> wrote:
> Hi,
>
> I am new to GWT and facing problem with Fileupload.
>
> I have a form which has multiple rails.
>
> In one of the rail, there is a form which has Fileupload widget.
>
> The form has button, which on click is supposed to send the file
> details to the servlet.
>
> In the servlet code, multipart is false , even the the encoding is set
> to  -
> ------ importFileUploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
>
> But in the servlet the multipart is shown as false.
>
> Servlet code
>
>   public String Importfile(String fileName)
>    {
>           HttpServletResponse response = this.getThreadLocalResponse();
>           HttpServletRequest request = this.getThreadLocalRequest();
>           HttpSession session = request.getSession();
>          boolean isMultipart =
> ServletFileUpload.isMultipartContent(request);
>       long uploadFileSize = 0;
>
>         response.setContentType("text/plain");
>
>         if (isMultipart)
>         {
>                 // do the processing on file.
>         }
>         else
>         {
>                 // do something else
>         }
>           return null;
>   }
>
> Form code.
>
>                 //Import file upload Form
>
>                 importFileUploadForm = new FormPanel();
>
>                 importFileUploadForm.setAction(IMPORT_ACTION);
>  // null value
>                 
> importFileUploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
>
>                 importFileUploadForm.setMethod(FormPanel.METHOD_POST);
>
>                 DOM.setElementAttribute(importFileUploadForm.getElement(), 
> "name",
> "importFileUploadForm");
>
>                 DOM.setElementAttribute(importFileUploadForm.getElement(), 
> "id",
> "importFileUploadForm");
>
>                 //Import file upload form submit and submit completed event 
> handlers
>
>                 importFileUploadForm.addFormHandler(new FormHandler()
>
>                 {
>
>                         public void onSubmit(FormSubmitEvent event)
>
>                         {
>
>                                 String filename = 
> importFileField.getFilename();
>
>                                 if (filename.trim().length() == 0)
>
>                                 {
>
>                                         Window.alert("Please select a file to 
> upload");
>
>                                         event.setCancelled(true);
>
>                                 }
>
>                                 else
>
>                                 {
>
>                                         Object objArr[] = {this,filename};
>                                         // get event manager
>                                         colMgr.DispatchEvent(impEvent);
>
>                                 }
>
>                     }
>
>                         @Override
>
>                         public void onSubmitComplete(FormSubmitCompleteEvent 
> arg0) {
>
>                                 // TODO Auto-generated method stub
>
>                                 //arg0.getSource().  
> .equals(obj)event.setCancelled(true);
>
>                         }
>
>                 });
>
>                 //File upload widget
>
>                 importFileField = new FileUpload();
>
>                 importFile.setStyleName("gwt-TextBox");
>
>                 importFileField.setName("importFile");
>
>                 DOM.setElementAttribute(importFileField.getElement(), "id",
> "importFile");
>
>                 final Button importClear = new Button("Clear");
>
>                 //submits the file import upload form
>
>                 importUpload.addClickHandler(new ClickHandler()
>
>                 {
>
>                         public void onClick(ClickEvent event)
>
>                         {
>
>                                 importFileUploadForm.submit();
>
>                         }
>
>             });
>
>                 //clears the file upload widget by replacing it with a new 
> copy
>
>                 importClear.addClickHandler(new ClickHandler()
>
>                 {
>
>                         public void onClick(ClickEvent event)
>
>                         {
>
>                                 //RootPanel rootPanel = 
> RootPanel.get("importFileUploadForm"); //
> get container div
>
>                                 
> DOM.removeChild(importFileUploadForm.getElement(),
> importFileField.getElement()); //remove input
>
>                                 importFileField = new FileUpload(); //create 
> replacement widget
>
>                                 importFileField.setStyleName("gwt-TextBox"); 
> //add style info
>
>                                 
> DOM.setElementAttribute(importFileField.getElement(), "id",
> "importFile"); //set id
>
>                                 
> DOM.setElementAttribute(importFileField.getElement(), "size",
> "75");//set size
>
>                                 importFileUploadForm.add(importFileField); 
> //add replacement
> widget into container div
>
>                         }
>
>                 });
>
>                 leftTopRail.add(importMgrHeader);
>
>                 leftTopRail.add(importFileUploadForm);
>
>                 importTabRootPanel.add(importFileField, 
> "importFileUploadForm");
>
>                 importTabRootPanel.add(importUpload, "importFileUploadForm");
>
>                 importTabRootPanel.add(importClear,"importFileUploadForm");
>
>                 this.leftTopRail = leftTopRail;
>
>         }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to