title: How to manage error message in Spring MVC
body: <p>I am new to spring MVC .My abc page is have one submit button. On click of submit button, abcHandler called which is inside xyzController.
  Just wondering how to achieve this scenario.</p>
  
  <p>-- If some error occurs then it should return some message.<br>
  -- It should stay in the same page , for me its abc page.</p>
  
  <p>I have tried this.The problem I am facing is that , i am getting the alert message as "You must have something...",
  but it is navigating to error page means a blank page. This is not suppose to happen.I want to show the message and stay in the same page.
  How can i achieve easily with spring MVC.
  Please suggest some idea.</p>
  
  <pre><code>public class xyzController extends MultiActionController implements InitializingBean {
  
  public ModelAndView abcHandler(HttpServletRequest request,HttpServletResponse response)throws Exception  {
  
  // session
  HttpSession session = request.getSession(true);
  
  String abc = "";
  if(abc != ""){
  
  }else{
  String error = "You must have xyzzzzzz";
  return new ModelAndView("2.0/error", "downloaderror", error);
  }
  
  return new ModelAndView();
  }
  }
  </code></pre>
  
  <p>My error.jsp is like this   </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="abc/js/jquery-1.9.0.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;c:if test="${not empty downloaderror}"&gt;
  &lt;script&gt;
      alert("You must have something...");        
  &lt;/script&gt;
  &lt;/c:if&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>