title: Model objects are not passed to jsps in Spring MVC - InternalResourceView - renderMergedOutputModel
body: <p>I am using JstlView Spring Tiles in my project.</p>
  
  <p>When i try to send <strong>form:errors</strong> from validator to jsp through controller,errors are not being dispayed in jsp</p>
  
  <p></p>
  
  <p>when i debug,</p>
  
  <p>1)errors are being printed in controller class before returning modelandview , from validator class.</p>
  
  <p>2)Then error are also being printed in JstlView class from controller class.</p>
  
  <p>So i think, requestDispatcher.forward(request, response) in jstlview class is not returning  model data to jsp.</p>
  
  <p>Because when i tried HttpServletRequest or HttpServletResponse objects to retrive errors in jsp , values are being dispalyed in jsp.</p>
  
  <p>Can some one help me in this used.</p>
  
  <p><strong>How can i send model data to jsp renderMergedOutputModel- RequestDispatcher , redirect method.</strong></p>
  
  <p>My code is as follows,</p>
  
  <p>JstlView class:</p>
  
  <pre><code>public class JstlView extends InternalResourceView {
  
   @Override
   protected void renderMergedOutputModel(Map&lt;String, Object&gt; model, HttpServletRequest request, HttpServletResponse response) throws Exception {
  
   // Determine the path for the request dispatcher.
   String dispatcherPath = prepareForRendering(request, response);
  
   // set original view being asked for as a request parameter
   request.setAttribute("partial", dispatcherPath.substring(dispatcherPath.lastIndexOf("/") + 1));
  
  // force everything to be template.jsp
   RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/template.jsp");
   requestDispatcher.forward(request, response);
  
   System.out.println("**********************"+model.get("userName"));
   }
  
  }
  </code></pre>
  
  <h1>Servlet.xml</h1>
  
  <pre><code>&lt;bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
  
      &lt;property name="viewClass" value="com.tms.web.view.JstlView" /&gt;
  
      &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
  
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code> private LoginValidator loginValidator;
       @Autowired
       public void setUserValidator(LoginValidator loginValidator) {
           this.loginValidator = loginValidator;
       }
  
         final RequestHandler  requestHandler = new RequestHandler();
         @RequestMapping(value = "/login", method = RequestMethod.GET)
         public ModelAndView login() {
            return new ModelAndView("login", "users", new users());
         }
  
     @RequestMapping(value = "/logins",method = RequestMethod.POST)
     public ModelAndView validateUser(@Valid users user, BindingResult result,@ModelAttribute("users")users users,ModelMap model,RedirectAttributes redirectAttributes,HttpServletRequest req) 
     {
         this.loginValidator.validate(user, result);
              if (result.hasErrors()) 
              {
                    model.putAll(result.getModel());//values not retuned to jsp
                    req.setAttribute("userName", result.getFieldError().getDefaultMessage().toString());  //working fine values retuned to jsp
                    return new ModelAndView("/login", model);
              }
             else
             {
                      //succes related code
                      return new ModelAndView(redirect, model);
             }    
        }   
  </code></pre>
  
  <p>Validator</p>
  
  <pre><code>@Component
  public class LoginValidator implements Validator {
  
    @Override
    public boolean supports(Class&lt;?&gt; clazz) {
  
      return clazz.isAssignableFrom(users.class);
    }
    @Override
    public void validate(Object obj, Errors errors) {
      users user = (users) obj;
      String userName = user.getUserName();
      String password = user.getPassword();
      validateuserName(userName,password, errors);
    }
  
    private void validateuserName(String userName, String password,Errors errors) {
      if (!(isValidString(userName))) {
         errors.rejectValue("userName", "userName.required","Username should not be blank");
      }
      else if(!(isValidString(password)))
      {
          errors.rejectValue("password", "password.required","Password should not be blank");
      }
    }
  
    private boolean isValidString(String str) {
      return isNotNull(str) &amp;&amp; (str.length() &gt; 0 ) &amp;&amp; !(str.isEmpty());
    }
  
    private boolean isNotNull(String str) {
      return str != null;
    }
  }
  </code></pre>
  
  <p>Jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html;charset=UTF-8; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1" %&gt;
  &lt;%@ page isScriptingEnabled="true" isELIgnored="false" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  
  
  
      &lt;form:form method="POST" action="/TMSWeb/logins"  commandName="users" modelAttribute="users"&gt;                                          
                                  &lt;input name="password" type="password" align="center"/&gt; 
                                  &lt;form:errors path="password" cssClass="error" element="div" /&gt; 
                                  &lt;input type="submit" class="buttonorange"  value="Login"/&gt;
              &lt;/form:form&gt;
  </code></pre>
  
  <p>In Spring MVC when I can access my beans in JSP without JstlView's, then, in my JSP I can write (${errors). But when the same JSP is a part of a tiles view, these properties aren't accessible. </p>
  
  <p>Can someone help me in this issue?  </p>