gwtencodingmulti-upload

How to pass the right cyrillic letters on server using MultiUploader in GWT?


I'm using MultiUploader in GWT and I wat to pass userNumber on server through servlet path.

MultiUploader muplDef = new MultiUploader();
muplDef.setServletPath(muplDef.getServletPath() + "?userNumber="
                + "ВАВАВАВАВ" + "&mode=" + "JPG"
                + "&hm=" + GWT.getPermutationStrongName());

My userNumber contains cyrillic letters "ВАВАВАВАВ" and on the server I get the wrong userNumber: ÐÐÐÐÐÐÐÐÐ.

 @Override
    public String executeAction(HttpServletRequest request,
            List<FileItem> sessionFiles) throws UploadActionException {
        try {
            request.setCharacterEncoding("UTF-8");
            userNumber = request.getParameter("userNumber");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
...

How to pass the right userNumber on server using MultiUploader in GWT? Thanks.

EDIT On my local tomcat everything works great, but on server I get the wrong userNumber. Even I wrote request.setCharacterEncoding("UTF-8") I still don't know what to do( I need help.


Solution

  • You need to URL-encode the parameters in your call (all or just the user number):

    String param = URL.encode("?userNumber="
                + "ВАВАВАВАВ" + "&mode=" + "JPG"
                + "&hm=" + GWT.getPermutationStrongName());
    
    muplDef.setServletPath(muplDef.getServletPath() + param);