Hi All, I am Ravi, i am Working on one Android Application in that i want to send data from Android Application to Server Through HTTPS Protocol.
in that i can read data that Server send to client in that i am successful. But when i trying to send data from Client to Https Server that time i am not able to receive that data at Server End. i post my Application Code here, This is my Client Code, public class MobHypeSDK { public void sendImageToHTTPS(String path) { //String url = "https://localhost:8443/MobHypeServer? actionType=sendImage"; try { System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol"); System.setProperty("javax.net.ssl.trustStore","keystore"); TrustManager easyTrustManager = new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException { // TODO Auto-generated method stub } public void checkServerTrusted( java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException { // TODO Auto-generated method stub } }; URL url = new URL("https://localhost:8443/MobHypeServer? actionType=sendImage"); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, new TrustManager[] { easyTrustManager }, null); HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory()); HttpsURLConnection shuc = (HttpsURLConnection) url.openConnection(); System.out.println("Connection Code--------->" + shuc.getResponseCode()); shuc.setDoInput(true); shuc.setDoOutput(true); shuc.setFollowRedirects(true); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str = in.readLine(); while(str != null) { System.out.println("DATA From Https Server------>" + str); str = in.readLine(); } OutputStreamWriter out = new OutputStreamWriter(shuc.getOutputStream()); out.write("OUT WriteFirst....."); out.write("OUT WriteFirst....."); out.flush(); out.close(); System.out.println("Data Are Written Successfully......."); } catch(Exception e) { e.printStackTrace(); } } } This is My Server Code, public class MobHypeServer extends HttpServlet { protected void doGett(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { response.setContentType("text/html"); String actionType = request.getParameter("actionType"); System.out.println("Action Type's value....."+actionType); ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream()); oos.writeChars("First DATA From Server"); oos.writeChars("Second DATA From Server"); oos.writeChars("Thirs DATA From Server"); oos.flush();oos.close(); DataInputStream input = new DataInputStream(request.getInputStream()); String str=""; while (null != ((str = input.readLine()))){ System.out.println("STR--------->" + str); if (str.length() >0){ str = str.trim(); if(!str.equals("")){ System.out.println(str); //str += str + "\n"; } } } input.close(); } catch(Exception e) { e.printStackTrace(); } } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.