title: How to call ModelAndView method or getting reference to it in JSP page?
body: <p>I reflect how is possible to call method or get property value using getter in ModelAndView through JSP page using extended class.</p>
  
  <p>For example:</p>
  
  <p>I would extends class ModelAndView to class View and implements there some methods to getting some data.</p>
  
  <pre><code>import org.springframework.web.servlet.ModelAndView;
  
  public class View extends ModelAndView {
  
      private Map store = new HashMap&lt;&gt;() ;
  
      public Object getElement(String index) {
          return store.get(index);
      }
  
      public void setElement(String index,Object o) {
           store.put(index,o);
      }
  
  }
  </code></pre>
  
  <p>Now controller which will handle approaching request.</p>
  
  <pre><code>public class WelcomeController extends AbstractController {
  
      private String viewName;
  
      @Override
      protected ModelAndView handleRequestInternal(
              HttpServletRequest request,
              HttpServletResponse response) throws Exception {
  
          View v = new View("example.jsp");
          v.setElement("test", "Hello im test!");
          return v
  
          // I would not use here method addObject();
          // how put reference to jsp page of View (ModelAndView)
          // code like this return StackOverflowError
          // v.addObject("reference_to_view",v);
      }
  
  }
  </code></pre>
  
  <p>Nothing remains, except getting my string test from View in JSP page:</p>
  
  <p>example.jsp</p>
  
  <pre><code>&lt;body&gt;
      &lt;h1&gt;WELCOME&lt;/h1&gt;
      // how can i here call method getElement of object View.
      ${this.getElement("test")}
      ${getElement("test")}
  &lt;/body&gt;
  </code></pre>
  
  <p>How can i call method getElement(); of object View which was returned from WelcomeController </p>