title: Spring MVC, handle errors in @service layer and send them to the jsp
body: <p>I seek the best way to handle error validation in the @service layer in a spring mvc application.</p>
  
  <p>I have a @Controller and a @Service class.</p>
  
  <p>My controller :</p>
  
  <pre><code>public String saveProduct(Product product) {
      myService.saveProduct(product);
      return "view";
  }
  </code></pre>
  
  <p>My service :</p>
  
  <pre><code>public void saveProduct(Product product) {
      // some validation here
      myDao.save(product);
  }
  </code></pre>
  
  <p>Now let's say that the validation leads to 2 or 3 errors (the color is not appropriate, the supplier can't deliver the product right now, and so on...) and I have to display all of them at the same time.</p>
  
  <p>How do I transmit those errors to my controller, and then to my jsp ? Using an "Errors" object ? An exception containing all those errors ?</p>
  
  <p>I've already looked here : <a href="https://stackoverflow.com/questions/3224749/passing-errors-back-to-the-view-from-the-service-layer">Passing errors back to the view from the service layer</a> but I can't find a convenient answer. Do I really have to create unchecked exceptions for EACH error ? And what if I have a 20 or 30 errors ?</p>