title: send data from jsp form to database in spring (without using servlets)
body: <p>i have a form where i want the user to fill it in and then hit a submit button which will send the data to a database.</p>
  
  <p>this is the form: </p>
  
  <pre><code>&lt;form:form method="POST" action="addQuestion" &gt;
  
     &lt;input type="text" name="questionId" /&gt;Enter Id&lt;br&gt;
     &lt;input type="text" name="theQuestion" /&gt;Enter Q &lt;br&gt;
     &lt;input type="text" name="category" /&gt;Enter Category&lt;br&gt;
     &lt;input type="text" name="correctAnswer" /&gt;Enter correct answer&lt;br&gt;
     &lt;input type="submit" value="Next"  &gt;
  
  &lt;/form:form&gt;
  </code></pre>
  
  <p>and addQuestion should be called in this webcontroller.java class</p>
  
  <pre><code>@RequestMapping(value = "/addQuestion", method = RequestMethod.POST)
      public ModelAndView addQuestion(Model model, @RequestParam(value="question", required = true)  String theQuestion , @RequestParam(value="questionId", required = true)  Integer questionId, @RequestParam(value="category", required = true)   String category, @RequestParam(value="correctAnswer", required = true)   String correctAnswer) throws SQLException{
          ViewController viewController = new ViewController();
          viewController.createQuestion(questionId, theQuestion, category, correctAnswer);
  
          return new ModelAndView("qFour", "question", new Question());
      }
  </code></pre>
  
  <p>and then viewController should be invoked which connects to the DAO to submit data to the database. however, at the moment, when submit is clicked it just refreshes the page or rather just deletes all the data entered into the input boxes</p>