Friday, October 29, 2010

Re: gwt FormPanel & servlet integration

On 29 oct, 08:24, hbaydarov <hbayda...@gmail.com> wrote:
> I'm just writing a simple FormPanel and a servlet that handle it.
> However, there is a problem while getting parameter from FormPanel.
> What I want to say :
>
>     formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
>     formPanel.setMethod(FormPanel.METHOD_POST);

[...]

> protected void doPost(HttpServletRequest req, HttpServletResponse
> resp)
>         throws ServletException, IOException {
>
>     System.out.println(req.getParameter("name")); // null! why?

getParameter only works when data is sent in application/x-www-form-
urlencoded (as multipart/form-data might be very big and contain
attached files, it would cost too much to parse it ahead from a
getParameter(), and getParameter won't give you the uploaded files).
You have to use something like Apache Commons FileUpload to read/
decode a multipart/form-data payload: http://commons.apache.org/fileupload/

--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment