title: How to redirect to pop-up after form submission with spring validator messages?
body: <p>I have one JSP page test.jsp in which one button is there "show Form". After clicking "show Form" a form is opening in pop-up which is a jsp page "form.jsp".</p>
  
  <p>For validating the fields of form.jsp I am using Spring validator.</p>
  
  <p>I want to submit the form page in pop-up and show the same "form.jsp" in same popup with spring validator error messages. Anybody having sugestions for this ??</p>
  
  <p>test.jsp</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  
  &lt;script&gt;
   function showForm()
  {
  
      var requestUrl="${pageContext.request.contextPath}/test/show/form;
  
      try{
          $.ajax(
          {
              type: 'GET',
              url: requestUrl,
              success: function(data){ 
                  $("#dialog_form").html(data);
                  $("#dialog_form").dialog( "open" );
  
              },
              error: function(xhr, ajaxOptions, thrownError){
                  console.log("Error in displaying rights");
              } 
          });
      }catch(e){
          console.log("Error in displaying rights");
      }
  }
  &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
           &lt;input class="button" value="Show Form" type="button" onClick="showForm();"&gt;
          &lt;div id="dialog_form"&gt;&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>form.jsp</p>
  
  <pre><code>&lt;form:form method="post" commandName="employee"  id="employeeForm" action="${pageContext.request.contextPath}/test/submit"&gt;
          &lt;p&gt;
             &lt;label&gt;Name&lt;/label&gt;
              &lt;span &gt;&lt;form:input path="name" id="nameId" /&gt;&lt;/span&gt; 
              &lt;span class="required" id="nameErrors"&gt;&lt;form:errors path="name"/&gt;&lt;/span&gt;
          &lt;/p&gt;
            &lt;p&gt;
             &lt;label&gt;Last Name&lt;/label&gt;
              &lt;span &gt;&lt;form:input path="lastName" id="lastNameId" /&gt;&lt;/span&gt; 
              &lt;span class="required" id="lastNameErrors"&gt;&lt;form:errors path="lastName"/&gt;&lt;/span&gt;
          &lt;/p&gt;
        &lt;input class="button" value="Submit" type="submit" id="submitButton"&gt;
      &lt;/form:form&gt;
  </code></pre>
  
  <p>in TestController.java</p>
  
  <pre><code>@RequestMapping(value = "/show/form", method = RequestMethod.GET)
      public ModelAndView showForm() {
          mav = new ModelAndView();
          Employee emp = new Employee();
         mav.addObject("employee", emp);
         mav.setViewName("show_form");
          return mav;
      }
  
  @RequestMapping(value = "/submit", method = RequestMethod.GET)
          public ModelAndView subForm(@ModelAttribut Employee employee, BindingResult result, HttpServletRequest request) {
              mav = new ModelAndView();
              validator.validate(employee);
             mav.addObject("employee", employee);
             mav.setViewName("show_form");
              return mav;
          }
  </code></pre>