title: How to send unicode characters to servlet by ajax??
body: <p>I am working on a login page which has a form of enctype multipart/formdata that contains input fields where user inputs data of any language. I am using <strong>ajax</strong> (<strong>FormData</strong>) to send the data to the server ,at the server i am not getting the data properly as i am not able to convert to unicode.  I have set page encoding to utf-8. I guess there's problem with the headers. <strong>Somebody please help me.</strong></p>
  
  <p>Here's my code :</p>
  
  <p><strong>Client:</strong></p>
  
  <pre><code>                    var formdata=new FormData();
                      formdata.append("servname",servname);
                      formdata.append("disptype1",disptype1);
                      formdata.append("text",text);
                      formdata.append("back",back);
                      formdata.append("servtype",servtype);
                      formdata.append("caption",caption);
                      formdata.append("selsubservices",selsubservices);
                      formdata.append("action","addinfo");
                      formdata.append("iconfile",iconfile);
                      $.ajax({
                          type: "POST",
                          url: 'settingServlet',
                          data: formdata,
                          //dataType: 'json',
                          //contentType: "multipart/form-data",
                          //processData: false,
                          contentType:false,
                          processData:false,
                          success: function (response) {     
                              processAddResponse(response);
                          },
                          error: function (error) {
                              alert("Error occured at" +error);
                          }
                      });
  </code></pre>
  
  <p><strong>Server :</strong></p>
  
  <pre><code>boolean isMultipart = ServletFileUpload.isMultipartContent(request);
              if (isMultipart)
                {
                  DiskFileItemFactory factory = new DiskFileItemFactory();
                  ServletFileUpload uploads = new ServletFileUpload(factory);
                  List&lt;FileItem&gt; formItems = uploads.parseRequest(request);
                  if (formItems != null &amp;&amp; formItems.size() &gt; 0)
                    {
                      for (FileItem item : formItems)
                        {
                          if (item.isFormField())
                            {
                              //upload formdata except files
                              String fieldname = item.getFieldName();
  
                              if (fieldname.equals("roomname"))
                            {
                             name = item.getString();//data corrupts here.
                             name = new String(roomname.getBytes("iso-8859-1"),"UTF-8");
                             name = convert(roomname);
                             name = JUtility.toHTML(roomname);
                            }
                         }
                     }
  </code></pre>