title: java.io.StreamCorruptedException In Android
body: <p>I have a question about my code.<br> It doesnt work perfectly
  Error Comes From this Line</p>
  
  <pre><code>ObjectInputStream obin=new ObjectInputStream(response.getEntity().getContent());
  </code></pre>
  
  <p>please help me guys</p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          StrictMode.ThreadPolicy policy=new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy);
  
          loginButton=(Button) findViewById(R.id.button1);
          loginButton.setOnClickListener(this);
  
          username=(EditText) findViewById(R.id.editText1);
          password=(EditText) findViewById(R.id.editText2);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
      @Override
      public void onClick(View arg0) {
          if (arg0== loginButton) {
              loadSettings();
          }
      }
  
      private void loadSettings(){
          try {
              String uname=username.getText().toString();
              String upass=new String(password.getText().toString());
  
              if (uname.equals("") || uname.equals(null) ||upass.equals("") ||upass.equals(null)) {
                  Toast.makeText(getBaseContext(), "Please Enter Username and Password", Toast.LENGTH_SHORT).show();
              }else{
                  postParameters=new ArrayList&lt;NameValuePair&gt;();
                  postParameters.add(new BasicNameValuePair("uname", uname));
                  postParameters.add(new BasicNameValuePair("upass", upass));
  
                  post("http://192.168.1.3:8080/and/log", postParameters);  
  
              }
          } catch (Exception e) {
              e.printStackTrace();
              Toast.makeText(getBaseContext(), e.toString()+".....Load", Toast.LENGTH_SHORT).show();
          }
      }
  
      private void post(String url, ArrayList&lt;NameValuePair&gt; postParameters){
          try {
  
  
  
              HttpClient client=getHttpClient();
  
              HttpPost request=new HttpPost(url);
  
              UrlEncodedFormEntity formEntity=new UrlEncodedFormEntity(postParameters);
  
              request.setEntity(formEntity);
  
              HttpResponse response=client.execute(request);
  
              ObjectInputStream obin=new ObjectInputStream(response.getEntity().getContent());
  
              //ObjectInputStream obin=new ObjectInputStream(response.getEntity().getContent());
  
              final HashMap hm=(HashMap) obin.readObject();
  
              if (hm.get("status").toString().equals("OK")) {             
                  Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_SHORT).show();
              }else if(hm.get("status").toString().equals("NO")) {                
                  Toast.makeText(getBaseContext(), "Not Success", Toast.LENGTH_SHORT).show();
              }
          } catch (Exception e) {
              e.printStackTrace();
              Toast.makeText(getBaseContext(), e.toString()+"...............", Toast.LENGTH_SHORT).show();
          } 
      }
  
      private HttpClient getHttpClient(){
          if (mHttpClient == null) {
              mHttpClient= new DefaultHttpClient();
              HttpParams params=mHttpClient.getParams();
              HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
              HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
              ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
          }
          return mHttpClient;
      } 
  </code></pre>
  
  <p>This Is Java Servlet</p>
  
  <pre><code>    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          try (PrintWriter out = response.getWriter()) {
  
          try {
  
  
              String uname=request.getParameter("uname");
              String upass=request.getParameter("upass");
              System.out.println(upass);
  
              ObjectOutputStream obut = new ObjectOutputStream(response.getOutputStream());
              HashMap hm = new HashMap();
  
              if(uname.equals("p") &amp;&amp; upass.equals("123")){
              hm.put("status", "OK");
              }else{
              hm.put("status", "NO");
              }
              obut.writeObject(hm); 
          } finally {
              out.close();
          }}
  
      }
  
      // &lt;editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."&gt;
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          processRequest(request, response);
      }
  
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          processRequest(request, response);      
      }
  }
  </code></pre>