title: Passing Java Object from Android as parameter to RESTful Webservice
body: <p>I'm new to Android and Web Services in java. I'm trying to pass a Java object or class as a parameter to a method in the web service. I'm using an android application as the client and everything works fine when ever I'm passing a string using but now I want to pass a String variable that contains a slash '/' so it doesn't seem to be working. So I thought that the best option was to pass in an Object as a parameter so I could get the values in whatever format they are from the webservice. Please how to I write the server side and client side codes.
  Here is my previous code for my web service</p>
  
  <pre><code>@Path("/Student")
  </code></pre>
  
  <p>public class StudentController {</p>
  
  <pre><code>StudentService studentService;
  
  @GET
  @Path("/{username},{password}")
  @Produces(MediaType.APPLICATION_JSON)
  public Student authenticate(@PathParam("username") String username, @PathParam("password") String password) {
  
      StringTokenizer st = new StringTokenizer(username, "/");
      String school = st.nextToken();
      studentService = new StudentService("Laurels");
  
      return studentService.validateStudent("Laurels/2015/"+username, "Laurels/2015/"+password);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my previous code for my android client </p>
  
  <pre><code>private class Authenticate extends AsyncTask&lt;Void, Void, Void&gt;{
  
      Snackbar snackbar = Snackbar.make(btnLogin, "Result", Snackbar.LENGTH_LONG);
  
      private int status;
      private Bundle bundle;
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          // Showing progress dialog
          pDialog = new ProgressDialog(LoginActivity.this);
          pDialog.setMessage("Please wait...");
          pDialog.setCancelable(false);
          pDialog.show();
      }
  
      @Override
      protected Void doInBackground(Void... arg0) {
  
          // Creating service handler class instance
          ServiceHandler sh = new ServiceHandler();
  
          String url = "http://192.168.42.209:8085/SchoolWebService/rest/Student/"+username+","+password;
          // Making a request to url and getting response
          String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
          Log.d("Response: ", "&gt; " + jsonStr);
  
          if (jsonStr != null) {
              try {
                  JSONObject c = new JSONObject(jsonStr);
  
                  String uname = c.getString("username");
                  String pword = c.getString("password");
                  String surname = c.getString("surname");
                  boolean validated = c.getBoolean("validated");
                  if(!validated){
                      snackbar.setText("Invalid Login").show();
                      status = 0;
                  }else{
                      snackbar.setDuration(Snackbar.LENGTH_SHORT).setText("Authenticated!").show();
                      status = 1;
                      bundle = new Bundle();
                      bundle.putString("username", username);
                      bundle.putString("password", password);
                      bundle.putBoolean("validated", validated);
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          } else {
              snackbar.setText("Connection Failed!").show();
          }
  
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          super.onPostExecute(result);
          // Dismiss the progress dialog
          if (pDialog.isShowing()) {
              pDialog.dismiss();
          }
          if(status == 1){
              Intent intent = new Intent(LoginActivity.this, MainActivity.class);
              intent.putExtras(bundle);
              startActivity(intent);
              finish();
          }
      }
  }
  </code></pre>