title: Call a JSP page through javascript on button click
body: <p>I am currently working on an MVC program where I need to call the <code>home.jsp</code> page when the user logs in from the <code>login.jsp</code>. I have written the code for the login and home controllers that render the views. But am not sure how to call the controllers' request mapping through my <code>custom.js</code> javascript file that I have under my resources.</p>
  
  <p><strong>custom.js</strong></p>
  
  <pre><code>document.getElementById('login_btn').addEventListener("click", function() {
      authorizationCheck();
  }, false);
  
  
  function authorizationCheck()
  {
      var username = document.getElementById('username_txt').value;
      var password = document.getElementById('password_txt').value;
  
      if(username == "admin" &amp;&amp; password == "123")
      {
         //code to load the home.jsp
      }
  }
  </code></pre>
  
  <p><strong>HomeController.java</strong></p>
  
  <pre><code>@Controller
  public class HomeController {
  
      private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
  
      /**
       * Simply selects the home view to render by returning its name.
       */
  
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public String login(Locale locale, Model model) {   
          return "login";
      }
  
      @RequestMapping(value = "/home", method = RequestMethod.GET)
      public String home(Locale locale, Model model) {
          logger.info("Welcome home! The client locale is {}.", locale);
  
          return "home";
      }
  }
  </code></pre>
  
  <p>I am quite new to this framework. So any suggestions on how to load a different jsp upon a button click will be highly appreciated.</p>