Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:32:01+00:00 2026-06-16T00:32:01+00:00

LoginFormController–>Post is invoked after the form is submitted/posted. At the end, it invokes another

  • 0

LoginFormController–>Post is invoked after the form is submitted/posted. At the end, it invokes another Controller called LandingFormController–>loadForm.

Well, in the loadForm the values in the Model seems to be empty. Is there a way I can persist a Bean in session or request and get it in the loadForm method? Bonus points: if you could point to some documents to refer 🙂

Thanks

@Controller
@RequestMapping(value="/login")
public class LoginFormController {  

@RequestMapping(method=RequestMethod.POST)
public ModelAndView post(@ModelAttribute User user, BindingResult result, SessionStatus status) {
    logger.info("post");
    new ReceiptUserValidator().validate(user, result);
    if (result.hasErrors()) {
        return new ModelAndView("login");
    }
    else {
        logger.info("Email Id: " + user.getEmailId());
        //status.setComplete();         

        Map<String, Object> model = new HashMap<String, Object>();
        model.put("userId", user.getEmailId());
        model.put("now", new Date().toString());

        return new ModelAndView("redirect:/landing.htm", "model", model);
    }
}

Controller B below that gets called

@Controller
@RequestMapping(value="/landing")
public class LandingFormController {    
    protected final Log logger = LogFactory.getLog(getClass());

    @RequestMapping(method=RequestMethod.GET)
    public String loadForm(Model model) {
        logger.info("LandingFormController loadForm: " + model.asMap().keySet());       
        return "landing";
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:32:02+00:00Added an answer on June 16, 2026 at 12:32 am

    The code is performing a redirect which causes the properties placed in the model to be lost. Use flash attributes to pass the attributes to the next controller.

    Flash attributes provide a way for one request to store attributes
    intended for use in another. This is most commonly needed when
    redirecting — for example, the Post/Redirect/Get pattern. Flash
    attributes are saved temporarily before the redirect (typically in the
    session) to be made available to the request after the redirect and
    removed immediately.

    LoginFormController

    @Controller
    @RequestMapping(value="/login")
    public class LoginFormController {  
    
    @RequestMapping(method=RequestMethod.POST)
    public ModelAndView post(@ModelAttribute User user, BindingResult result,
          SessionStatus status, final RedirectAttributes redirectAttrs) {
    
        logger.info("post");
        new ReceiptUserValidator().validate(user, result);
        if (result.hasErrors()) {
            return new ModelAndView("login");
        }
        else {
            logger.info("Email Id: " + user.getEmailId());
            //status.setComplete();         
    
            redirectAttrs.addFlashAttribute("userId", user.getEmailId());
            redirectAttrs.addFlashAttribute("now", new Date().toString());
    
            return new ModelAndView("redirect:/landing.htm", "model", model);
        }
    }
    

    Documentation

    As an alternative solution you could simply not perform a redirect from the controller.

    Appending retrieving solution.

    Modify the loadForm

     public String loadForm(@ModelAttribute("user") User user) {
            logger.info("LandingFormController loadForm: " + user.getEmailId());        
            return "landing";
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display a login screen using presentModalViewController on iPad. LoginFormController *controller
Here is my html code <form runat=server> Hello, i'm login page Enter Name <asp:TextBox
I'm an MVC newbie so this might sound trivial.I have my 2 Views(EnterLogin.aspx,ShowLogin.aspx) in
This may have been asked many times but I have not been able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.