1

this is the scenario, user enter to login page, user signup to the application, the application record a new user and then the application redirect/forward the user for authentication, the handler methods are in the same controller.

The problem is that the forward is not redirecting to the View tile, and the view tile is called 'dashboard'. Below the code:

Signup process

 @RequestMapping(value = "/signup", method = RequestMethod.POST)
  public String signup(HttpServletRequest request, HttpServletResponse response, @Valid SignupForm signupForm, BindingResult result, Model model) throws IOException, ServletException {
        String language= Utility.getBrowserLanguageCode( request.getHeader("Accept-Language") );
//      userService.saveSignUp(signupForm, language);
    LoginForm loginForm= new LoginForm();
    loginForm.setJ_username(signupForm.getNewUserId());
    loginForm.setJ_password(signupForm.getNewUserPassword());   

    request.removeAttribute("signupForm");
    request.setAttribute("loginForm", loginForm);

    return "forward:/login";    // Also, I tried with redirect with the same result :(
  }  

forwar/redirect to

    //----- login called on submit the user credentials.
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public String customLogin(HttpServletRequest request, HttpServletResponse response, @Valid LoginForm loginForm, BindingResult result, Model model) throws IOException, ServletException {
      // do whatever validation you want to do
      String username = loginForm.getJ_username();
      String password = loginForm.getJ_password();

      return 'dashboard';
  }

Here the tiles settings:

  <definition extends="default" name="dashboard">
    <put-attribute name="body" value="/WEB-INF/views/dashboard.jspx"/>
  </definition>

And what I have also is the following security process, and what I see is that my filter is being call a lot, and the following is the log. (this case is similar to: Stackoverflow #: 20332050 )

00:19:34,604 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'redirect:/login'
00:19:34,604 DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.RedirectView: name 'redirect:/login'; URL [/login]] in DispatcherServlet with name 'quo'
00:19:34,606 DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
00:19:52,130 DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
00:20:11,960 DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Closing JPA EntityManager in OpenEntityManagerInViewFilter
00:20:13,497 DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
...

23:30:53,685 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'dashboard'
23:30:53,686 DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.tiles2.TilesView: name 'dashboard'; URL [dashboard]] in DispatcherServlet with name 'quo'
23:30:53,687 DEBUG org.springframework.web.servlet.view.tiles2.TilesView - Added model object 'loginForm' of type [com.jarbits.security.LoginForm] to request in view with name 'dashboard'
23:30:53,687 DEBUG org.springframework.web.servlet.view.tiles2.TilesView - Added model object 'org.springframework.validation.BindingResult.loginForm' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'dashboard'
23:30:53,687 DEBUG org.springframework.web.servlet.view.tiles2.TilesView - Added model object '_dashboardList' of type [java.util.ArrayList] to request in view with name 'dashboard'
23:30:53,729 DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request

And what I see is the filter is being call for anything and suddenly the tile view name is changed to 'index' (exactly as the case 20332050)

org.springframework.web.servlet.view.tiles2.TilesView: name 'index'
TylerH
  • 20,799
  • 66
  • 75
  • 101
Jrr
  • 167
  • 1
  • 4
  • 14
  • Does your `Controller` have method annotated with `@RequestMapping(value = "/login", method = RequestMethod.GET)` ? – Rohan Oct 17 '14 at 06:03
  • Yes it does, have a look to "forwar/redirect to" section above, the return 'dashboard' is called, but once returns to front-end the view tile name is reseted. – Jrr Oct 17 '14 at 13:52
  • Hi @pappu_kutty, did you find any feedback for your case: 20332050 ? – Jrr Oct 17 '14 at 19:20

0 Answers0