GWT/GXT File-Upload Example

2,487 views
Skip to first unread message

Sascha Hoffmann

unread,
Aug 15, 2012, 5:13:52 AM8/15/12
to google-we...@googlegroups.com
Hi everybody

I have only a little question. Is anybody here who knows a good example how to upload a file with gwt oder gxt? I found two in the net but they don't work. I would apreciate it if someone could help me.

Sascha

Chak Lai

unread,
Aug 15, 2012, 10:42:53 AM8/15/12
to google-we...@googlegroups.com

Sascha Hoffmann

unread,
Aug 16, 2012, 8:05:33 AM8/16/12
to google-we...@googlegroups.com
Thanks that will help. Do you know where I can get an example with a servlet? I know not much about servlets.

Jens

unread,
Aug 16, 2012, 8:11:55 AM8/16/12
to google-we...@googlegroups.com

Thanks that will help. Do you know where I can get an example with a servlet? I know not much about servlets.

You could use Apache Commons FileUpload to read the form data in your servlet. The library also provides a FileUploadServlet I think. Just google for it.

-- J. 

Rob

unread,
Aug 16, 2012, 7:15:01 PM8/16/12
to google-we...@googlegroups.com

Sascha Hoffmann

unread,
Aug 17, 2012, 6:11:27 AM8/17/12
to google-we...@googlegroups.com
I copied the sourcecode in my project and it works fine, but if I try to read the header in my servlet its nothing there.
Where is my mistake?
here is my servlet:
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;

public class FileServiceImpl extends HttpServlet {
   
    private static final long serialVersionUID = 1L;
   
    private FileItem uploadedFileItem;
     
    @Override
    protected void service(final HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
       
        @SuppressWarnings("rawtypes")
        java.util.Enumeration e = request.getParameterNames();
        java.io.PrintWriter pw = response.getWriter();
        String attrib;
       
        while (e.hasMoreElements()) {
            pw.print(
                (attrib = (String) e.nextElement())
                    + " : "
                    + request.getParameter((String) attrib)
                    + "<br>"
                    );
        }
 
        pw.print("<br>Fertig!");

    }
}


Am Mittwoch, 15. August 2012 16:42:53 UTC+2 schrieb Chak Lai:
Reply all
Reply to author
Forward
0 new messages