title: Multiple if else statement with parameter in doGet() servlet
body: <p>I am having some problem when trying to execute different method in servlet doGet(). So when my button on click, it will pass along the eventID:</p>
  
  <pre><code>viewDtlEventBtn.setOnClickListener(new OnClickListener(){
          public void onClick(View v){
              Intent eventDtlIntent = new Intent(context, EventDetail.class);
              eventDtlIntent.putExtra("eventID", eventIDTV.getText());
              startActivity(eventDtlIntent);
          }
      });
  </code></pre>
  
  <p>Then in my EventDetail class, I am executing the method in AsyncTask class:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.event_detail);
      context = this; 
      Bundle extras = getIntent().getExtras();
      if (extras != null) {
          eventID = extras.getString("eventID");
      }       
      eventModel.setEventID(eventID);
      new GetEventDetailAsyncTask(context).execute(eventModel);
  }
  </code></pre>
  
  <p>And in my AsyncTask class, I am calling the method in my controller which retrieving the JSON returned from servlet:</p>
  
  <pre><code>@Override
  protected Double doInBackground(Event... params) {
      try {
          eventCtrl.getEventDetailByID(params[0]);
      } catch (JSONException e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>And in my controller class:</p>
  
  <pre><code>public Event getEventDetailByID(Event event) throws JSONException {
      Event eventModel = new Event();
      String page;
      JSONArray jsonArray;
      String eventID = event.getEventID();
  
      try {
          HttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet(ENeighbourhoodActivity.URL
                  + "?getEventDetailByID&amp;eventID=" + eventID +"");
          HttpResponse response = client.execute(request);
          HttpEntity entity = response.getEntity();
          String responseString = EntityUtils.toString(entity, "UTF-8");
          page = "{\'EventDetail\':" + responseString + "}";
          try {
              JSONObject jsonObject = new JSONObject(page);
              jsonArray = jsonObject.getJSONArray("EventDetail");
              int length = jsonArray.length();
              for (int i = 0; i &lt; length; i++) {
                  JSONObject attribute = jsonArray.getJSONObject(i);
                  String eventName = attribute.getString("eventName");
                  eventModel.setEventName(eventName);
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
      } catch (IOException e) {
          e.printStackTrace();
      }
      return event;
  }
  </code></pre>
  
  <p>And basically from here, I am accessing the servlet. And in my doGet() in serlvet class:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
      JSONArray jsonArray = new JSONArray();
      PrintWriter out = response.getWriter();
  
      if (request.getParameter("getAllEvent") != null) {  
      }
  
      catch (JSONException je) {
          System.out.println(je.getMessage());
      } catch (Exception exc) {
          System.out.println(exc.getMessage());
      }
      out.println(jsonArray.toString());
      }
  }
  </code></pre>
  
  <p>I already have one if statement for some other methods. I wonder how should I pass the getEventDetailByID and the eventID parameter into servlet so that it knows which method to runs.</p>
  
  <p>Thanks in advance.</p>