title: reading the form data in servlet. data posted with post method and servlet called with ?q=test1
body: <p>Hey I am trying to read the form data in a servlet sent with post method. And the servlet is called as <code>OnlineExam?q=saveQuestion</code>. Now the servlet is working as:</p>
  
  <pre><code>public class OnlineExam extends HttpServlet {
  protected void doGet(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
  if(request.getParameter("q").equals("saveQuestion")){
                  /*
                   * Save the question provided with the form as well as save the uploaded file if any.
                   */
                  saveQuestion(request);
              }
  }
  
  protected void doPost(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
  //      doGet(request, response);
          saveQuestion(request);
      }
  public String saveQuestion(HttpServletRequest request){         
          System.out.println(request.getParameter("question"));
  
          return "";
  
      }       
  }
  </code></pre>
  
  <p>HTML form:</p>
  
  <pre><code>&lt;form action="OnlineExam?q=saveQuestion" method="post"&gt;
          &lt;fieldset&gt;
          &lt;legend&gt;Question&lt;/legend&gt;
          &lt;textarea class="questionArea" id="question" name="question"&gt;Enter Question.&lt;/textarea&gt;
          &lt;br class="clearFormatting"/&gt;               
          &lt;input class="optionsInput" value="optionA" name="optionA" onfocus = "clearValues('optionA')" onblur = "setValues('optionA')"/&gt;
          &lt;br class="clearFormatting"/&gt;
  
          &lt;input class="optionsInput" value="optionB" name="optionB" onfocus = "clearValues('optionB')" onblur = "setValues('optionB')"/&gt;
          &lt;br class="clearFormatting"/&gt;
  
          &lt;input class="optionsInput" value="optionC" name="optionC" onfocus = "clearValues('optionC')" onblur = "setValues('optionC')"/&gt;
          &lt;br class="clearFormatting"/&gt;
  
          &lt;input class="optionsInput" value="optionD" name="optionD" onfocus = "clearValues('optionD')" onblur = "setValues('optionD')"/&gt;
          &lt;br/&gt;
          &lt;input class="optionsInput" value="answer" name="answer" onfocus="clearValues('answer')" onblur="setValues('answer')"/&gt;     
          &lt;input type="submit" value="Save" /&gt;
          &lt;input type="reset" value="Cancel" /&gt;
          &lt;button style="display: none" onclick="return deleteQuestion()" &gt;Delete&lt;/button&gt;
          &lt;/fieldset&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>So can anyone illustrate how the servlet is actually called. I mean what is the flow of control i.e. how the things works in this servlet. </p>
  
  <p>And how could i read the param1 there in servlet.</p>
  
  <p>ps: i don't want to post form with get method.</p>