title: How to know from which jsp page the request has come to the controller in Spring MVC
body: <p>I am developing an app where <code>LoginForm.jsp</code> and <code>UserRegistration.jsp</code> will lead to <code>UserAccount jsp</code> page on specific action.In <code>LoginForm</code> when a user presses a 'Login' button ->UserAccount form is displayed.In UserRegistration Form when details are entered and submitted ->UserAccount form is displayed.
  Below is the controller code when a request comes as <code>UserAccount.html</code></p>
  
  <pre><code> @RequestMapping(value="/UserAccount.html", method = RequestMethod.POST)
          public ModelAndView userAccountForm(@Valid @ModelAttribute("user") UserDetails user,BindingResult result) {
  
              if(result.hasErrors())
  
              {   System.out.println(result.getAllErrors());
                  ModelAndView model1=new ModelAndView("UserRegistration");
                  return model1;
              }
              // User validation
  
  
              System.out.println(user.getAccountType());
              userDAO.create(user);
  
              ModelAndView model1 = new ModelAndView("UserAccount");
              return model1;
  
  
  }
  </code></pre>
  
  <p>LoginForm.jsp</p>
  
  <pre><code>&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;h1
          style="background-color: green; color: Yellow; padding: 10px; text-align: center;"&gt;Mybank
          Online Login&lt;/h1&gt;
  
      &lt;form:errors path="user.*" /&gt;
      &lt;form action="/MyBankProject/UserAccount.html" method="post"&gt;
          &lt;div
              style="background-color: yellow; color: black; padding: 10px; text-align: center;"
              align="center"&gt;
              &lt;p&gt;
                  User ID &lt;input type="text" name="userName" /&gt;
              &lt;/p&gt;
              &lt;p&gt;
                  Password &lt;input type="password" name="password" /&gt;
              &lt;/p&gt;
              &lt;input type="submit" value="Login" /&gt; &lt;a
                  href="/MyBankProject/userRegistration.html"&gt;New User?&lt;/a&gt;
          &lt;/div&gt;
      &lt;input type="hidden" name="page" value="LoginForm"/&gt;
  
      &lt;/form&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>UserRegistration.jsp</p>
  
  <pre><code>&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;h1&gt;${headerMessage}&lt;/h1&gt;
      &lt;h3&gt;USER REGISTRATION&lt;/h3&gt;
  
      &lt;form:errors path="user.*" /&gt;
  
      &lt;form action="/MyBankProject/UserAccount.html" method="post"&gt;
          &lt;table border="1" style="width:100%" &gt;
  
              &lt;tr&gt;
                  &lt;td&gt;FirstName :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="firstName" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;LastName :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="lastName" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;User's EmailId :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="emailId" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;user's gender :&lt;/td&gt;
                  &lt;td&gt;&lt;select name="gender" multiple&gt;
                          &lt;option value="M"&gt;Male&lt;/option&gt;
                          &lt;option value="F"&gt;Female&lt;/option&gt;
                  &lt;/select&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;user's age :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="age" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;user's DOB :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="dOB" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Account Type :&lt;/td&gt;
                  &lt;td&gt;&lt;select name="accountType" multiple&gt;
                          &lt;option value="Savings"&gt;Savings&lt;/option&gt;
                          &lt;option value="Current"&gt;Current&lt;/option&gt;
                          &lt;option value="FixedDeposit"&gt;Fixed Deposit&lt;/option&gt;
                  &lt;/select&gt;
                  &lt;td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Amount :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="amount" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;UserName&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="userName" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Password&lt;/td&gt;
                  &lt;td&gt;&lt;input type="password" name="password" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;User's Address :&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;country: &lt;input type="text" name="address.country" /&gt;&lt;/td&gt;
                  &lt;td&gt;city: &lt;input type="text" name="address.city" /&gt;&lt;/td&gt;
                  &lt;td&gt;street: &lt;input type="text" name="address.street" /&gt;&lt;/td&gt;
                  &lt;td&gt;pincode:&lt;input type="text" name="address.pincode" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;&lt;button type="submit"&gt;Submit&lt;/button&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="button" onclick="history.back();"
                      value="Cancel"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
       &lt;input type="hidden" name="page" value="UserRegistration"/&gt;
  
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now for me I need to know the jsp page from which the UserAccount invoked ,to perform different actions based on that.
  I am new to Spring MVC and searched all over the internet for the solution.</p>