List of usage examples for org.apache.http.client ClientProtocolException printStackTrace
public void printStackTrace()
From source file:com.da.daum.DaumCafeBungList.java
public static void main(String[] args) { DaumCafeBungList cfl = new DaumCafeBungList(); log.warn("Logging Works"); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); try {//w w w .j av a2s .c o m // https://msp.f-secure.com/web-test/common/test.html // String body = // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f"); /* * String body = CHttpUtil.DownloadHtml( * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on" * ); System.out.println(body); */ String nPage = "1"; String p_author_id = "bluesman"; String p_gnum = ""; // ga String p_host_url = ""; // ga if (args.length > 0) { nPage = args[0]; } if (args.length > 1) { p_author_id = args[1]; } if (args.length > 2) { STORY_DIR = args[2]; } if (args.length > 3) { p_host_url = args[3]; SO_URL = p_host_url; /* * host_url = "http://www."+SO_URL; photo_url = * "http://photo."+SO_URL+"/album/theme/"; story_url = * "http://story."+SO_URL+"/honor/"; */ } cfl.executeURL(nPage, p_author_id, p_gnum); // cfl.executeAuthorList(nPage, p_author_id, p_gnum); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.da.daum.DaumCafeOneLineList.java
public static void main(String[] args) { DaumCafeOneLineList cfl = new DaumCafeOneLineList(); log.warn("Logging Works"); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); try {/*from ww w. j a v a 2 s .co m*/ // https://msp.f-secure.com/web-test/common/test.html // String body = // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f"); /* * String body = CHttpUtil.DownloadHtml( * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on" * ); System.out.println(body); */ String nPage = "1"; String p_author_id = ""; String p_gnum = ""; // ga String p_host_url = ""; // ga if (args.length > 0) { nPage = args[0]; } if (args.length > 1) { p_author_id = args[1]; } if (args.length > 2) { STORY_DIR = args[2]; } if (args.length > 3) { p_host_url = args[3]; SO_URL = p_host_url; /* * host_url = "http://www."+SO_URL; photo_url = * "http://photo."+SO_URL+"/album/theme/"; story_url = * "http://story."+SO_URL+"/honor/"; */ } cfl.executeURL(nPage, p_author_id, p_gnum); // cfl.executeAuthorList(nPage, p_author_id, p_gnum); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.da.daum.DaumCafeLevelUpList.java
public static void main(String[] args) { DaumCafeLevelUpList cfl = new DaumCafeLevelUpList(); log.warn("Logging Works"); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); try {//from ww w.j a v a 2 s. c o m // https://msp.f-secure.com/web-test/common/test.html // String body = // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f"); /* * String body = CHttpUtil.DownloadHtml( * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on" * ); System.out.println(body); */ String nPage = "1"; String p_author_id = "bluesman"; String p_gnum = ""; // ga String p_host_url = ""; // ga if (args.length > 0) { nPage = args[0]; } if (args.length > 1) { p_author_id = args[1]; } if (args.length > 2) { STORY_DIR = args[2]; } if (args.length > 3) { p_host_url = args[3]; SO_URL = p_host_url; /* * host_url = "http://www."+SO_URL; photo_url = * "http://photo."+SO_URL+"/album/theme/"; story_url = * "http://story."+SO_URL+"/honor/"; */ } cfl.executeURL(nPage, p_author_id, p_gnum); // cfl.executeAuthorList(nPage, p_author_id, p_gnum); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:Main.java
public static String makeGETRequest(String url) { HttpClient httpclient = new DefaultHttpClient(); HttpGet get = new HttpGet(url); // Fazendo a requisicao ao servidor try {/*w w w.j a v a 2 s . co m*/ ResponseHandler<String> responseHandler = new BasicResponseHandler(); return httpclient.execute(get, responseHandler); } catch (ClientProtocolException e) { e.printStackTrace(); return null; } catch (IllegalStateException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } }
From source file:de.randec.MVBMonitor.Downloader.java
static String downloadJson(String url) throws IOException { String data = ""; try {//from w w w . jav a2 s . co m // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpResponse response = httpClient.execute(httpPost); data = EntityUtils.toString(response.getEntity(), "utf-8"); //data = EntityUtils.toString(response.getEntity()); } catch (ClientProtocolException e) { e.printStackTrace(); } //unescape escape codes (Umlaute) return StringEscapeUtils.unescapeHtml4(data); }
From source file:Main.java
/** * Makes a POST call to the server.//from w ww.ja v a 2 s.c o m * @param params 0-> Call Method = POST; 1-> URL; ... -> Params * @return */ public static String httpPost(String... params) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(params[1]); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); for (int i = 1; i + 1 < params.length; i += 2) { nameValuePairs.add(new BasicNameValuePair(params[i], params[i + 1])); } if (!nameValuePairs.isEmpty()) { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); System.out.println(response.toString()); return response.toString(); } catch (ClientProtocolException e) { e.printStackTrace(); return "Client Protocol Exception"; } catch (IOException e) { e.printStackTrace(); return "POST: Failed to connect (" + params[1] + ")"; } }
From source file:net.felixrabe.unleashthecouch.Utils.java
public static String getDocument(String couchDbDocUrl) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(couchDbDocUrl); HttpResponse response = null;//from w ww . j a v a2s .c o m try { response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); if (entity != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); entity.writeTo(baos); return new String(baos.toByteArray(), "UTF-8"); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:org.opf_labs.fmts.fidget.droid.PRONOMSigGenerator.java
/** * @param sigdef//w w w . j a v a 2s.co m */ public static void generatePRONOMSigFile(SigDefSubmission sigdef) { DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpPost httpost = new HttpPost(SERVICE_URL); httpost.setEntity(new UrlEncodedFormEntity(createNameValuePairs(sigdef), Consts.UTF_8)); HttpResponse response = httpclient.execute(httpost); HttpEntity entity = response.getEntity(); // Print out: IOUtils.copy(entity.getContent(), System.out); // Finish up: EntityUtils.consume(entity); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } }
From source file:Main.java
public static void sendData(final String targetUrl, final String idField, final String tempField, final String feelingField, final String symptomsField, final String id, final String temp, final String feeling, final ArrayList<String> symptoms) { new Thread(new Runnable() { public void run() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(targetUrl); try { // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair(idField, id)); nameValuePairs.add(new BasicNameValuePair(tempField, temp)); nameValuePairs.add(new BasicNameValuePair(feelingField, feeling)); for (int i = 0; i < symptoms.size(); i++) { nameValuePairs.add(new BasicNameValuePair(symptomsField, symptoms.get(i))); }/*from www.ja v a2 s.co m*/ // Must put this extra pageHistory field here, otherwise Forms will reject the // symptoms. nameValuePairs.add(new BasicNameValuePair("pageHistory", "0,1")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }).start(); }
From source file:no.hig.gsd.quizgame.ServerUtilities.java
/** * Register this account/device pair within the server. * * @return whether the registration succeeded or not. *//*from ww w . java2 s .com*/ public static String register(final Context context, final String regId) { Log.i("remote", "registering device (regId = " + regId + ")"); String usm = LoginActivity.usm; String retSrc = ""; try { HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://89.250.116.142/Quizgame/jaxrs/quizgame/gcm"); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("username", usm)); nameValuePairs.add(new BasicNameValuePair("regId", regId)); post.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8)); HttpResponse httpResponse = client.execute(post); HttpEntity entity = httpResponse.getEntity(); retSrc = EntityUtils.toString(entity); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (retSrc.equals("success")) { return status = "success"; } else { return status = "failure"; } }