title: using jQuery ajax with servlet jsp
body: <p>I have a jsp form <strong>validate.jsp</strong> which contains 2 text fields where user enters his/her roll number/name. I have also written some validation code using javascript to verify the input. </p>
  
  <p>Now after collecting the input I forward these two parameters to another page <strong>result.jsp</strong> using jQuery ajax as shown below:</p>
  
  <pre><code>$("#student_result").load("result.jsp?"+ $.param( { rollNo: rollNo, name: name }));
  </code></pre>
  
  <p>Now my result.jsp page has to display result of the person whose roll no or name has been entered by the user. So, this <strong>result.jsp</strong> page contains all database logic(java code). But conventionally we should write all the business logic in a servlet. So I want to do this. </p>
  
  <p>But, as you can see, I am loading the contents of <strong>result.jsp</strong> dynamically using ajax inside the <strong>validate.jsp</strong> page. If I use a servlet I need to use requestDispatcher which will forward to and hence load the entire <strong>result.jsp</strong> page!</p>
  
  <p>I don't want to do that! I still want to load <strong>result.jsp</strong> page contents dynamically in the <strong>validate.jsp</strong> page. How to do that?</p>
  
  <p>Or will there be any complications if I keep the entire database logic in <strong>result.jsp</strong> file? </p>