hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David <pc.adi...@gmail.com>
Subject javawebstart
Date Tue, 16 Mar 2010 16:26:23 GMT
Hi :)

I trying to deploy my application with javawebstart and httpclient.

the application runs ok before using httpclient, but when I use it, the
application does not work.

I tried this code in an normal application and work perfect.

I read this, but is for the legacy api.
http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/SocketFactoryWrapper.java?view=markup&pathrev=451784

please, I need they help.

DefaultHttpClient httpclient = null;
try {
   httpclient = new DefaultHttpClient();
   httpclient.getCredentialsProvider().setCredentials(
              new AuthScope("192.168.2.1", 80),
              new UsernamePasswordCredentials("felipe", "passFelipe"));

   HttpHost proxy = new HttpHost("192.168.2.1", 3128);
   httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);

   HttpPost method = new HttpPost("
http://192.168.2.1/applet_server/gen_codigo");

   System.out.println("executing request" + method.getRequestLine());
   HttpResponse response = httpclient.execute(method);
   HttpEntity entity = response.getEntity();

   logger.trace("----------------------------------------");
   logger.trace(response.getStatusLine());
   if(response.getStatusLine().getStatusCode() ==
HttpStatus.SC_UNAUTHORIZED) {            return "";
   }

   if(response.getStatusLine().getStatusCode() == HttpStatus.SC_BAD_REQUEST)
{
      if(entity != null) {
        logger.error(EntityUtils.toString(entity));
      }
   }

   if (entity != null) {
       long len = entity.getContentLength();
       if (len != -1 && len < 2048) {
          passBD = EntityUtils.toString(entity);
       } else {
          logger.warn("Demasiado grande el resultado=" + len);
       }
    }

} catch (Exception e) {
logger.error("Error al obtener codigo desde servlet, continuando sin
codigo", e);
} finally {
if(httpclient != null) {
try {
httpclient.getConnectionManager().shutdown();
} catch (Exception e) {}
}
}
return passBD;

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message