Category Archives: apache-commons-httpclient

Apache HTTP Client 3 does not use pre-emptive authentication on some URL’s

I have two REST URL's. One is /accessmanager/sessions POST and the other one is /accessmanager/sessions/{token} POST.

The code goes through the following method, ONLY the URL is different.

private String doLogin(final String username, final String password, final String path,
        final int... expectedSatusCodes) throws AcmaException {

    // Setup credentials
    Credentials defaultcreds = new UsernamePasswordCredentials(username, password);

    String userCredentials = username + ":" + password;     

    // Setup HTTP client, prepare for login
    HttpClient client = this.getClient();

    client.getState().setCredentials(AuthScope.ANY, defaultcreds);

    // Setup POST method
    PostMethod method = new PostMethod(path);

    try {
        RequestEntity body = new StringRequestEntity("none", (String) null, (String) null);
        method.setRequestEntity(body);

        ObjectMapper mapper = new ObjectMapper();
        AccessManagerRESTImpl.LOG.debug("RETURNED === " + mapper.writeValueAsString(body));
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
        throw new AcmaException(ex);
    } catch (JsonProcessingException e) {
        .....
    }

    Header locationHeader = null;
    try {
        this.executeMethod(client, method);

        AccessManagerRESTImpl.LOG.debug("Response " + method.getStatusLine().toString());

        this.checkStatusCode(method, expectedSatusCodes);

        locationHeader = method.getResponseHeader(AccessManagerRESTImpl.HTTP_HEADER_LOCATION);
    } finally {
        method.releaseConnection();
    }


    .....

    return returnedToken;
}

Now, the first URL always works with Basic Auth. But the second one always return 400 Bad Request: Missing Authorization header.

I have checked that the credentials are OK and added to the Client's state. All is fine. So I am clutching at straws why this second call always fails. I know about pre-emptive authentication so I tried with

method.setRequestHeader("Authorization", basicAuth);

And then it works. Problem is, I am not allowed to upgrade the client, so I can't move to HttpClient 4 and I can't add this "Authorization" header.

But still, why does the first URL always work and why does the second with the {token} never work? As this is the same httpclient code:

private HttpClient getClient() throws AcmaException {

    if (this.httpclient == null) {
        this.httpclient = new HttpClient(this.connectionManager);

        this.httpclient.getHostConfiguration().setHost(this.otasUri.getHost(), this.otasUri.getPort(),
                this.easyhttps);

        int timeOut = AccessManagerRESTImpl.HTTP_CLIENT_TIMEOUT;
        if (timeOut > 0) {
            HttpConnectionParams params = this.httpclient.getHttpConnectionManager().getParams();
            params.setConnectionTimeout(timeOut);
        }
    }

    return this.httpclient;
}

The Rest API of both URL's contains the Basic Auth path param, so on server side it is all OK. Also tried the second URL with Curl. That also works fine.

Any hint/tip is greatly appreciated!

UPDATE

So I found out that the URL with the {param} never uses pre-emptive AUTH. But the one without param, just plain /accessmanager/sessions does use pre-emptive.

Can anybody explain this?

HCP JEE6 Application with Destination fails when server does not support TLS 1.0

We are consuming RESTful services external to a Hana Cloud Platform Java application. We are able to interact with these destinations setup in HCP via the Apache HttpClient (v4.1.3) provided as part of the application JEE6 profile and other HCP libraries, the application is configured to use JRE 7.

The integration infrastructure vendor we are connecting to, disabled TLSv1.0 recently and since then we are getting errors when trying to connect to the REST services.

This is the stacktrace:

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:421)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:150)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:575)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at com.sap.core.connectivity.httpdestination.client.RequestDirectorExtender.execute(RequestDirectorExtender.java:47)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at com.sap.core.connectivity.httpdestination.impl.AbstractHttpClientWrapper$2.execute(AbstractHttpClientWrapper.java:141)
at com.sap.core.connectivity.httpdestination.impl.AbstractHttpClientWrapper$2.execute(AbstractHttpClientWrapper.java:1)
at com.sap.core.connectivity.httpdestination.impl.AbstractHttpClientWrapper.executeOperation(AbstractHttpClientWrapper.java:300)
at com.sap.core.connectivity.httpdestination.impl.AbstractHttpClientWrapper.execute(AbstractHttpClientWrapper.java:277)
at com.sap.core.connectivity.httpdestination.impl.AbstractHttpClientWrapper.execute(AbstractHttpClientWrapper.java:132)
at com.sap.core.connectivity.httpdestination.impl.AbstractHttpClientWrapper.execute(AbstractHttpClientWrapper.java:126)
at my.domain.hcp.HttpRequestSupport.service(HttpRequestSupport.java:124)
at my.domain.gap.proxy.ProxyServlet.service(ProxyServlet.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.sap.core.communication.server.CertValidatorFilter.doFilter(CertValidatorFilter.java:156)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.eclipse.virgo.web.enterprise.security.valve.OpenEjbSecurityInitializationValve.invoke(OpenEjbSecurityInitializationValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at com.sap.core.jpaas.security.auth.service.lib.AbstractAuthenticator.invoke(AbstractAuthenticator.java:170)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at com.sap.core.tenant.valve.TenantValidationValve.invokeNextValve(TenantValidationValve.java:168)
at com.sap.core.tenant.valve.TenantValidationValve.invoke(TenantValidationValve.java:94)
at com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:38)
at com.sap.core.js.monitoring.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:27)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:807)

We have tried adding the JVM arguments to the Java application to force it to use TLSv1.1 or TLSv1.2 and not use TLSv1.0:

-Dhttps.protocols=TLSv1.1,TLSv1.2

Setting the JVM argument does nothing, it seems like the Apache HttpClient library ignores this setting. Is there another way to force the Apache HttpClient (v4.1.3) to a newer version of TLS?

Ajax js call , Httpclient java impact on server

We have a server which will handle servlet call and fetch the data. So we have two different type of clients

  1. Java script client ,through ajax calls we make servlet call.
  2. Http-Client java to make servlet call using NIO.

Note : Both are GET calls only.

Does these two different ways of calling servlet have any difference. Will there be any difference of resources on server handling these different mediums....

400 – Bad Request on Apache POST sending JSON

I'm trying to make a REST call from my class using the Apache. But its giving the 400 exception when I print the response of the REST service. Kindly find the code below and let me know the changes that needs to be made to make it working,

    List<NameValuePair> pickup = new ArrayList<NameValuePair>();
    ArrayList<HashMap> pickupItemList = new ArrayList<HashMap>();

    String [] productIds = prop.getArray("vproductIDs");
    String [] quantities = prop.getArray("vquantities");
    String [] tprices = prop.getArray("vtprices");
    String [] bprices = prop.getArray("vbprices");

    HashMap pickupObjMap = new HashMap<String, Object>();
    pickupObjMap.put("loyaltyId",prop.getString("loyaltyId"));
    pickupObjMap.put("loyaltyFName",prop.getString("loyaltyFName"));
    pickupObjMap.put("orderId",prop.getString("orderId"));
    pickupObjMap.put("locationId",prop.getString("locationId"));
    pickupObjMap.put("consignmentId",prop.getString("consignmentId"));
    pickupObjMap.put("description",prop.getString("description"));
    pickupObjMap.put("retailerId",prop.getString("retailerId"));
    pickupObjMap.put("pickupType",Integer.parseInt(prop.getString("pickupType")));
    pickupObjMap.put("email",prop.getString("email"));
    pickupObjMap.put("loyaltyLName",prop.getString("loyaltyLName"));
    pickupObjMap.put("status",prop.getString("status"));

    for(int i=0; i<productIds.length ; i++){
        HashMap map = new HashMap<String, Object>();
        map.put("sku", productIds[i]);
        map.put("quantity", Double.parseDouble(quantities[i]));
        map.put("totalPrice", Double.parseDouble(tprices[i]));
        map.put("basePrice", Double.parseDouble(bprices[i]));
        pickupItemList.add(map);
    }
    pickup.add(new BasicNameValuePair("pickupItemList", pickupItemList.toString()));
    pickup.add(new BasicNameValuePair("pickupObj", pickupObjMap.toString()));
    pickup.add(new BasicNameValuePair("ovclid", prop.getString("ovclid")));

        HttpPost httppost = new HttpPost("Target URL");
        try {
            httppost.setEntity(new UrlEncodedFormEntity(pickup));
            httppost.setHeader("Content-Type", "application/json");
            HttpClient httpclient = new DefaultHttpClient();
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
            if (bufferedReader != null) {
                int cp;
                StringBuilder sb = new StringBuilder();
                while ((cp = bufferedReader.read()) != -1) {
                    sb.append((char) cp);
                }
                System.out.println("String Response......."+sb);
                bufferedReader.close();
            }
            System.out.println("Response......."+entity.getContent());
        } catch (Exception e) {
            e.printStackTrace();

        }

Below is the response that I get upon making the REST Call.

Unexpected character ('p' (code 112)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') 
at [Source: [email protected]; line: 1, column: 2]

NoClassDefFoundError when runnung on server using apache commons httpclient lib

i'm writing a dynamic-web-project with wildfly as my web-server by java
in this project, i want to connect with other server
the library i'm using is apache.commons
however, the function works when i run as application
but once i run as server, it comes out an exception, NoClassDefFoundError, pointing at the line i new the object
( ConnectUtil util = new ConnectUtil() ) <- line of error triggered
i have tried to import the .jar below but still not working

  • comments-codec-1.10
  • comments-fileupload-1.3.1
  • comments-httpclient-3.1
  • comments-io-2.4
  • comments-lang-2.6
  • comments-logging-1.2
  • comments-ssl
  • how can i solve this?

    here's some code in ConnectUtil.java:

    public Response openUrl(String host, String url, int port, 
        HashMap<String, String> params, int timeout) {
    Response result = new Response();
        // init PostMethod object.
    Protocol mHttps = new Protocol("https", new EasySSLProtocolSocketFactory(), port);
    
    HttpClient client = new HttpClient();
    client.getHostConfiguration().setHost(host, port, mHttps);
    
    client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
    client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
    
    byte[] response = null;
    PostMethod method = new PostMethod(url);
    
    try {
        int code = client.executeMethod(method);
    
    } catch (Exception e) {
        logger.error(ExceptionUtil.getPlainStackTrace(e));
    } finally {
        if (method != null)
            method.releaseConnection();
    }
    return result;
    

    }

    and the stack trace is:

    ERROR [io.indertow.request] (default-55) UT005023: Exception handling request to /MyWebServicePath: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/protocal/SecureProtocalSocketFactory
    

    error happens when ConnectUtil util = new ConnectUtil()

    thanks

    org.apache.commons.httpclient.HttpClient multithreading calls crash

    Hi all I use apache's httpclient to make restcalls, everything is working fine, When multiple thread are using this method my app crashes. What is the implementation for this class that is MultithreadSafe.

    Here is my code.

            httpClient = new HttpClient();
    
            HttpMethod method = null;
            method = new GetMethod();
    
               ... method creation...
    
            httpClient.executeMethod(method);
            method.releaseConnection();
    

    Thanks in advance. Juan

    http client 3.0.1 sometimes stuck while reading response

    we use apache httpclient 3.0.1 in prod. environment. It generally works OK but sometimes it can not read response from the server. And unfortunately thread is get stucked for hours.

    And in the log the following lines appear for hours unless restart the application:

    2014-12-15 18:29:58,328 DEBUG enter HttpParser.readLine(InputStream, String)
    2014-12-15 18:29:58,328 DEBUG enter HttpParser.readRawLine()
    2014-12-15 18:29:58,328 DEBUG  enter HttpConnection.readLine()
    

    Note: All the timeout properties are set to reasonable values.

    HttpGetType result = new HttpGetType();
            HttpClient client = new HttpClient(connectionManager);
            client.getHttpConnectionManager().getParams().setConnectionTimeout(HTTP_CONNECTION_TIMEOUT);
            client.getHttpConnectionManager().getParams().setSoTimeout(HTTP_READ_TIMEOUT);
            PostMethod method = new PostMethod(url);
            if (proxy) {
                HostConfiguration config = new HostConfiguration();
                config.setHost(PROXY_IP);
                config.setProxy(PROXY_IP, PROXY_PORT);
                client.setHostConfiguration(config);
            }
    
            logger.info("post url:" + url);
            logger.info("sent post:" + body);
            try {
                method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
                method.getParams().setSoTimeout(HTTP_READ_TIMEOUT);
                // method.setRequestEntity(new StringRequestEntity(body, "text/plain","UTF-8"));
                method.setRequestEntity(new StringRequestEntity(body));
                client.executeMethod(method); 
                if (method.getStatusCode() == HttpStatus.SC_OK) {
                    BufferedReader br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
                    String line = null;
                    StringBuffer respBuf = new StringBuffer();
                    while ((line = br.readLine()) != null) {
                        respBuf.append(line);
                    }
                    result.setParams(true, respBuf.toString());
                    logger.info("received post:" + result.getMessage());
                } else {
                    logger.warn("httppost return code:" + method.getStatusCode());
                }
            } catch (Exception e) {
                logger.error(e);
            } finally {
                if (method != null)
                    method.releaseConnection();
            }
    

    When should the HttpClient be closed?

    I am building an Android app that will fire multiple HTTP requests (say a request every second) to a server to fetch data. What are the best practices I must follow?

    Should I create and close the client after each request, like the following?

    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
    
    try {
        HttpPost request = new HttpPost("http://yoururl");
        StringEntity params = new StringEntity(json.toString());
        request.addHeader("content-type", "application/json");
        request.setEntity(params);
        httpClient.execute(request);
    // handle response here...
    } catch (Exception ex) {
        // handle exception here
    } finally {
        httpClient.close();
    }
    

    Or should I create a client initially, use it for all requests and then finally close it when I'm done with it?

    Apache httpClient error on Android

    I have a desktop Java application to upload an image to server using Apache Commons httpClient lib (v4.3.6) and I am trying to replicate the solution in Android.

    The issue is that I get different response on executing the below statement on Java (which is correct) and Android (incorrect)

    HttpResponse response = client.execute(post);
    

    I referred to the post at HttpClient from apache in Android? which provides some information, but did not help me.

    I also tried to use the "Android port httpClient jar files" v4.3.3 and v.4.3.5 from https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html but was unsuccessful, as I got NoClassDefFoundError exception on executing

    MultipartEntityBuilder entity = MultipartEntityBuilder.create();
    

    I have currently switched back to using default java build jar files for HttpClient on Android.

    Below is my current code in Android (java is exactly same except the imageFilePath). Any pointers or help is greatly appreciated!

      HttpClient client = new DefaultHttpClient();
      String url="https://mywebsite.com/search/upload";
      String imageFilePath = Environment.getExternalStorageDirectory().getPath() +"/test.jpg"; 
      HttpPost post = new HttpPost(url);
      String boundary = "-------------" + System.currentTimeMillis();
      post.setHeader("Content-type", "multipart/form-data; boundary="+boundary);
    
      MultipartEntityBuilder entityB = MultipartEntityBuilder.create();
      entityB.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
      entityB.setBoundary(boundary);
    
      entityB.addPart("bih",new StringBody("200"));
      entityB.addPart("biw",new StringBody("160"));
      entityB.addPart("encoded_image", new FileBody(new File(imageFilePath)));  // Code snippet A
    
     //  Code snippet B - I am not sure if snippet A or snippet B is correct to add an encoded image
     // if(file != null)
     //    {
     //        entityB.addBinaryBody("encoded_image", file);
     //    }
    
      entityB.addPart("image_url",new StringBody(""));
      entityB.addPart("image_content",new StringBody(""));
      entityB.addPart("filename",new StringBody(""));
      entityB.addPart("h1",new StringBody("en"));
    
    
      HttpEntity entity = entityB.build();
      post.setEntity(entity);
    
     HttpResponse response = client.execute(post);
    

    httpClient POST and multipart and encoding

    I have a Java Applet which uses httpclient to POST multipart files to a Servlet, the Applet for some unknow reason for me, POST ISO-8859-1 to the server side (Servlet), on server side I must handle UTF-8. I'm sending a file e.g. ├ęclave and on server side I'm getting ?clave.

    Here's my code Applet side:

            PostMethod post = new PostMethod(urlDest + "&jsessionid="+ sessionId);
            Part[] parts = {
                    new StringPart("uploadDir", dirUpload ? "true" : "false"),
                    new StringPart("uploadedBasePath", URLEncoder.encode(path,
                            "UTF-8")),
                    new StringPart("uploadedFullPath",
                            URLEncoder.encode(toUpload.getParentFile()
                                    .getAbsolutePath(), "UTF-8")),
    
                    new StringPart("uploadedFileName", URLEncoder.encode(
                            toUpload.getName(), "UTF-8")),
                    new StringPart("uploadedTableName", URLEncoder.encode(
                            tableName, "UTF-8")),
                    new StringPart("uploadedFileModificationDate",
                            URLEncoder.encode(dateString, "UTF-8")), part };
    
            post.setRequestEntity(new MultipartRequestEntity(parts, post
                    .getParams()));
    
    
            if (toUpload.getName().toLowerCase().endsWith(".msg")) {
                part.setContentType("message/rfc822");
            }
    
            if (this.authorization != null) {
                post.addRequestHeader("Authorization", this.authorization);
            }
    
            HttpClient client = new HttpClient();
            client.getParams().setParameter("http.protocol.content-charset",
                    "UTF-8");
    
            int status = client.executeMethod(post);
            sResult = post.getResponseBodyAsString();
            //sResult = new String(post.getResponseBody(),"UTF-8");
    
            if (sResult == null || sResult.equals(""))
                sResult = "";
    
            post.releaseConnection();
    

    Just in case, server side extract...

    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        logger.info("Recieved new Upload request");
    
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
    
    
    
    
        StringBuffer respContent = new StringBuffer("");
    
        if (ServletFileUpload.isMultipartContent(req)) {
            ServletFileUpload upload = new ServletFileUpload(
                    new DiskFileItemFactory());
    
            upload.setFileSizeMax(maxsize);
            upload.setProgressListener(new UploadProgressListener(req
                    .getSession()));
    
            // use all lower case tags because of browser compatibility issues
            // (IE)
            respContent.append("<uploadresult>");
            try {
                // Parse the request
                FileItemIterator iter = upload.getItemIterator(req);
    
                while (iter.hasNext()) {
                    FileItemStream item = iter.next();
    
                    String name = item.getFieldName();
                    InputStream stream = item.openStream();
                    if (item.isFormField()) {
                        logger.info("Form field " + name + " with value "
                                + Streams.asString(stream) + " detected.");
                    } else {
                        FileItemHeaders headers = item.getHeaders();
                        if (headers != null) {
                            Iterator<String> it = headers.getHeaderNames();
                            while (it.hasNext()) {
                                String hname = it.next();
                                System.out.println(hname + "="
                                        + headers.getHeader(hname));
                            }
                        }
    
                        FileWrapper f = new FileWrapper();
                        ByteArrayOutputStream bout = new ByteArrayOutputStream();
    
                        Streams.copy(stream, bout, true);
    
                        String contentType = "application/octet-stream";
                        if (item.getContentType() != null
                                && item.getContentType().length() > 0) {
                            contentType = item.getContentType();
                        }
    
                        f.setContent(bout.toByteArray());
                        f.setContentType(contentType);
                        f.setFileName(item.getName());
                        System.out.println("coding file name servlet side:" +  new String (item.getName().getBytes(),"UTF-8"));
                        System.out.println("coding file name servlet side:" +  URLDecoder.decode(item.getName(),"UTF-8"));
                        //
                        System.out.println("Testing iso");
                        System.out.println("coding file name servlet side:" +  new String (item.getName().getBytes(),"ISO-8859-1"));
                        System.out.println("coding file name servlet side:" +  URLDecoder.decode(item.getName(),"ISO-8859-1"));
    
    
                        Long id = store.store(f);
                        respContent.append("<file>");
                        respContent.append("<contenttype>" + contentType
                                + "</contenttype>");
                        respContent.append("<name>" + f.getFileName()
                                + "</name>");
                        respContent.append("<id>" + id + "</id>");
                        respContent.append("</file>");
                    }
    
                    stream.close();
                }
            } catch (FileUploadIOException fioe) {
    
                try {
                    throw fioe.getCause();
                } catch (FileSizeLimitExceededException fslee) {
                    System.out.println("fioe == " + fioe);
                    respContent.append("<error>");
                    respContent.append("<message></message>");
                    respContent.append("<maxsize>" + fslee.getPermittedSize()
                            / 1024 / 1024 + "</maxsize>");
                    respContent.append("<actualsize>" + fslee.getActualSize()
                            / 1024 / 1024 + "</actualsize>");
                    respContent.append("</error>");
                } catch (Throwable t) {
                    throw new RuntimeException(t);
                }
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
            respContent.append("</uploadresult>");
    
        resp.setCharacterEncoding("UTF-8");
        resp.getWriter().print(respContent.toString());
    

    Thank you very much, I really apreciate your help...