title: Post data using Volley error Occure "NetworkDispatcher.run:Unhandled exception java.lang.NullPointerException: Attempt to invoke virtual method'"
body: <p>error ""NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()'" "
  UI contains two password edit text fields and an button, which i'm intented to save the password entered by the user to the Server. but when ever i clicked the submit button the above error is displayed by the function onErrorResponce of the StringRequest.
  below is the code to save password to the server.</p>
  
  <pre><code>  private void savePasswordToServer() {//pass1&amp;pass are two edittext field objects
          if(pass1.getText().toString().equals(pass.getText().toString()))
          {
              String url = new URLConstants().BaseURL+"save_password.php";
              StringRequest request = new StringRequest(Request.Method.POST, url,new Response.Listener&lt;String&gt;() {
                  @Override
                  public void onResponse(String response) {
                      try
                      {
                          JSONObject jsonObject = new JSONObject(response);
                          boolean e = jsonObject.getBoolean("error");
                          if(!e)
                          {
                              Toast.makeText(getApplicationContext(), "password change successful", Toast.LENGTH_SHORT).show();
                              Intent intent = new Intent(getApplicationContext(),HomeScreen.class);
                              startActivity(intent);
                          }
                          else
                              Toast.makeText(getApplicationContext(),jsonObject.getString("error_details"),Toast.LENGTH_LONG).show();
                      }catch (JSONException e)
                      {
                          Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_LONG).show();
                      }
                  }
              }, new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      Toast.makeText(getApplicationContext(),"error VOLLEY "+error.getMessage(),Toast.LENGTH_LONG).show();
                  }
              })
              {
                  @Override
              public Map&lt;String, String&gt; getParams()
                  {
                      Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
                      params.put("rollno",rollno);
                      params.put("password",pass1.getText().toString());
                      return params;
                  }
              };
              MySingleton.getInstance(this).addToRequestQueue(request);
          }
          else
          {
              pass1.setError("wrong password");
              return;
          }
  }
  </code></pre>
  
  <p>and the following is error generated in AndroiMonitor</p>
  
  <pre><code>03-12 11:35:55.020 2742-2803/? E/Volley: [155] NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                                       java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                                           at libcore.net.UriCodec.encode(UriCodec.java:132)
                                           at java.net.URLEncoder.encode(URLEncoder.java:57)
                                           at com.android.volley.Request.encodeParameters(Request.java:413)
                                           at com.android.volley.Request.getBody(Request.java:399)
                                           at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:236)
                                           at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:210)
                                           at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:106)
                                           at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)
                                           at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)
  </code></pre>
  
  <p>please help me</p>