So in any way you will send multipart message to the server. The multipart
message have same structure like normal message request. Have header and
body. The key difference is the body structure. The body contain more then
one message in his structure. Example:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="frontier"

This is a message with multiple parts in MIME format.
--frontier
Content-Type: text/plain

This is the body of the message.
--frontier
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
--frontier--

So you need to parse this message to get the data out of the body. I post
you one example before how to parse multipart message. You can access the
parameters like this "httpRequest.getParameter("warehouse")". If its null
you probably don't send it correctly. Use firebug to see the traffic between
client and server.

On Fri, Oct 23, 2009 at 6:19 PM, YoeZ <[email protected]> wrote:

>
>
> yes, of course I put the multipart in client code:
>
>     form.setAction(GWT.getModuleBaseURL() + "uploadfileservlet");
>     form.setEncoding(FormPanel.ENCODING_MULTIPART);
>     form.setMethod(FormPanel.METHOD_POST);
>
> I have a form with uploadfile widget, and some textbox.
> the uploaded file was successfully sent to server,, but the textbox
> item is null return in servlet.
>
> is there any other way to uploadfile with some field (texboxes)?
> instead of using formpanel?
>
>
>
> On Oct 23, 12:20 pm, QBox <[email protected]> wrote:
> > Sohttp://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/g.
> ..
> > <http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/g..
> .>
> > Class FormPanel
> >
> > A panel that wraps its contents in an HTML <FORM> element.
> >
> > YoeZ say that he use This panel so it will be multipart ;)
> >
> >
> >
> > On Thu, Oct 22, 2009 at 8:57 PM, Sudeep S <[email protected]> wrote:
> > > multipart requests have to be sent via a FORM panel
> >
> > > On Thu, Oct 22, 2009 at 6:53 PM, Lazo Apostolovski <[email protected]
> >wrote:
> >
> > >> Its probably a multipart message :S
> >
> > >> Try googling for how to accept multipart message on the server side
> >
> > >> here is some example but i don't know if you find usefull.
> >
> > >> public HashMap<String, InputStream> parseMultipartMessage(
> > >>      HttpServletRequest request) {
> >
> > >>    mapWithStreams = new HashMap<String, InputStream>();
> >
> > >>    boolean isMultipart =
> ServletFileUpload.isMultipartContent(request);
> > >>    try {
> > >>      if (isMultipart) {
> > >>        FileItemFactory factory = new DiskFileItemFactory();
> > >>        ServletFileUpload upload = new ServletFileUpload(factory);
> >
> > >>        List<FileItem> items = upload.parseRequest(request);
> >
> > >>        for (FileItem item : items) {
> > >>          mapWithStreams.put(item.getFieldName(),
> item.getInputStream());
> > >>        }
> > >>      } else {
> > >>        mapWithStreams.put(DEFAULT_KEY, request.getInputStream());
> > >>      }
> > >>    } catch (FileUploadException e) {
> > >>      e.printStackTrace();
> > >>    } catch (IOException e) {
> > >>      e.printStackTrace();
> > >>    }
> > >>    return mapWithStreams;
> >
> > >> In normal message (not multipart) data from the text fields come like
> > >> the body of the message. If you try to transfer file in normal message
> > >> then Stream is send like the body of the message. So you can transver
> > >> only Parameters or only stream. If you want to transfer parameters and
> > >> stream in same message you need to use multipart message. In multipart
> > >> message InputStream come on server like a body of the message. If that
> > >> input stream contain multipart message you need to parse that message.
> > >> So in one part you will have values from input fields and in other
> part
> > >> you will have Stream for uploaded file. Read about multipart messages
> on
> > >> the wiki site. Code abowe will parse all input streams from multipart
> > >> message and place them to the HasMap. The Key in HashMap is the File
> > >> name. You can access to streams later when you need them. To the
> > >> parameters you can access on the same way like you deed before:
> >
> > >>    request.getParameter("parameterName");
> >
> > >> Good luck.
> >
> > >> YoeZ wrote:
> > >> > Hey abhiram,
> >
> > >> > I still have a problem in server side,, can you tell me how to catch
> > >> > variable from client.
> >
> > >> > Let say I have a textbox in client.
> >
> > >> > Textbox txtComment = new Textbox;
> > >> > txtComment.setName("txtComment");
> > >> > txtComment .setText("hello");
> >
> > >> > in server side:
> > >> > I've tried:
> > >> > String varXXX = (String) request.getParameter("txtComment");
> >
> > >> > but that's not working. :(
> >
> > >> > and I've also tried like this :
> >
> > >> >         try {
> > >> >             List items = upload.parseRequest(request);
> > >> >             Iterator it = items.iterator();
> > >> >             while (it.hasNext()) {
> > >> >                 FileItem item = (FileItem) it.next();
> > >> >                 if (item.isFormField()) {
> > >> >                       String name = item.getFieldName();
> > >> >                       if (name.equals("txtComment")) {
> > >> >                               ret = item.getString();
> > >> >                       }
> > >> >                     return ret;
> > >> >                 }
> > >> >             }
> > >> >         } catch (FileUploadException e) {
> > >> >             return null;
> > >> >         }
> >
> > >> > but still null return.
> >
> > >> > can you tell me how to catch it.
> >
> > >> > regards
> >
> > >> > On Oct 21, 12:32 am, abhiram wuntakal <[email protected]> wrote:
> >
> > >> >> Hey Yoez,
> >
> > >> >>   Not sure if it helps. But i have a workaround solution for this.
> Make
> > >> it a
> > >> >> two-step process. First use a RemoteServiceServlet to pass across
> your
> > >> >> variables to the server side and then save these values into some
> > >> variables
> > >> >> on the server side.
> >
> > >> >>  Then you can use a HTTPServlet to pass across your file contents
> to
> > >> the
> > >> >> server side. Now you have the file as well as the variables.
> >
> > >> >>  HTH,
> > >> >> Cheers,
> > >> >> Abhiram
> >
> > >> >> On Mon, Oct 19, 2009 at 6:12 PM, YoeZ <[email protected]> wrote:
> >
> > >> >>> thanks ian,, but i'm using GWT and tried to uploadfile which is
> must
> > >> >>> using FormPanel.
> > >> >>> I have successfully upload my file to server with UploadFile
> widget,
> > >> >>> but I have another textboxes too. and dunno how to catch inside
> > >> >>> FormPanel.
> >
> > >> >>> On Oct 19, 7:15 pm, Ian Bambury <[email protected]> wrote:
> >
> > >> >>>> You'll stand more chance of an answer if you ask that question in
> a
> > >> Java
> > >> >>>> forum. This is a GWT group.
> > >> >>>> Ian
> >
> > >> >>>>http://examples.roughian.com
> >
> > >> >>>> 2009/10/19 YoeZ <[email protected]>
> >
> > >> >>>>> hello... please help
> >
> > >> >>>>> On Oct 18, 12:31 am, YoeZ <[email protected]> wrote:
> >
> > >> >>>>>> Hi.
> >
> > >> >>>>>> I have 1 form panel with some textboxes and file upload.
> > >> >>>>>> the question is, how to get variables from client/form panel in
> > >> >>>>>> servlet?
> > >> >>>>>> i created DTO/Pojo object to hold variables in client, but i
> donk
> >
> > >> >>> know
> >
> > >> >>>>>> how to catch in servlet..
> >
> > >> >>>>>> please help
> >
> > >> >>>>>> thanks
> >
>

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

Reply via email to