You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by David <pc...@gmail.com> on 2010/03/16 17:26:23 UTC
javawebstart
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;