title: Spring mvc: best practice to navigate between two jsps
body: <p>I am using spring mvc + spring security to build a simple web application. I implemented the login/logout (spring mvc) but i want to provide also a registration jsp accessible directly from the login.jsp. Basically i just need a simple link from the login.jsp to the regsiter.jsp without passing any parameters or whatever. I just want to ask you what is the best practice to achieve this?</p>
  
  <p>Is there any way to navigate directly between the two jsps without routing the request down to the controller? (or this is not really a spring mvc way?) To be honest my only "problem" is just to have a separate method in the register controller which does nothing just routes the request to the register jsp. I mean:</p>
  
  <p><strong>RegisterController</strong></p>
  
  <pre><code>@Controller  
  public class RegisterController {
  
    @RequestMapping(value="/view_register.htm", method = RequestMethod.POST)
    /** Navigates to the register page */
    public String navigateToRegistration(ModelMap model) {
      return "register";
    }
  
    @RequestMapping(value="/register.htm", method = RequestMethod.POST)
    /** Handles request from the registration page and registers the user */
    public String registerUser(ModelMap model) {
  
      // hard stuff to register the user
      return "welcome";
    }
  
  }
  </code></pre>
  
  <p><strong>WEB-INF/pages/login.jsp</strong></p>
  
  <pre><code>......
  &lt;tr&gt;
     &lt;td&gt;Don't have an account yet.&lt;/td&gt;
     &lt;td&gt; &lt;a href="&lt;c:url value='view_register.htm' /&gt;"&gt;Register here&lt;/a&gt;
     &lt;/td&gt;
  &lt;/tr&gt;
  ......
  </code></pre>
  
  <p><strong>WEB-INF/pages/register.jsp</strong></p>
  
  <pre><code>......
  &lt;form name='registration' action="&lt;c:url value='register.htm' /&gt;"
          method='POST'&gt;
  ......
  </code></pre>
  
  <p><strong>WEB-INF/web.xml</strong> - routing each request to spring mvc
      ......
      
              mvc-dispatcher
              /
       </p>
  
  <p><strong>WEB-INF/mvc-dispatcher-servlet</strong></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;import resource="classpath:/applicationContext.xml" /&gt;
  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Is my implementation correct? This is the mvc way? I just want to know whether i understand this well and not doing any antipattern stuff. The thing what confuses me is really this additional small method in the regsitration controller which does nothing just navigates from the login to register. Is there at least any naming convention for this kind of methods? Would you recommend rather a ForwardController which could act as a Manager/Dispatcher and would just manage this kind of navigation requests?</p>