title: Spring MVC - The @SessionAttributes and status.setComplete()
body: <p>I'm facing a problem I don't really know how to solve.
  I am developing a Bug Tracker (learning purposes only). I have a page to create a new issue and one page to edit an issue. Both, for now, have their own controllers.</p>
  
  <p><strong>EditIssueController.java</strong></p>
  
  <pre><code>@Controller
  @RequestMapping(value = "/issues/{issueId}")
  @SessionAttributes("issuePackage")
  public class EditIssueController {
  
      @Autowired
      private IssueService issueService;
  
      [...]
  
      @ModelAttribute("issuePackage")
      public IssueTagEnvironment populateIssue (@PathVariable("issueId") Integer issueId) {
  
          IssueTagEnvironment issueTagEnv = new IssueTagEnvironment();
          issueTagEnv.setIssue(issueService.getIssueById(issueId));
  
          return issueTagEnv;
      }
  
      @InitBinder
      public void initBinder (WebDataBinder binder) {
  
          [...]
      }
  
      @RequestMapping(value = "/edit", method = RequestMethod.GET)
      public ModelAndView editIssue (@PathVariable("issueId") Integer issueId,
                                     @ModelAttribute("issuePackage") IssueTagEnvironment issuePackage) {
  
          ModelAndView mav = new ModelAndView("/issues/EditIssue");
  
          [...]
  
          IssueTagEnvironment issueTagEnv = new IssueTagEnvironment();
          issueTagEnv.setIssue(issueService.getIssueById(issueId));
  
          [...]
          mav.addObject("issuePackage", issueTagEnv);
  
          return mav;
      }
  
      @RequestMapping(value = "/edit", method = RequestMethod.POST)
      public String updateIssue (@ModelAttribute("issuePackage") IssueTagEnvironment issuePackage,
                                 BindingResult result) {
  
          if (result.hasErrors() == true) {
              return "redirect:/issues/{issueId}/edit";
          }
  
          issueService.updateIssue(issuePackage.getIssue());
  
          return "redirect:/issues/{issueId}";
      }
  }
  </code></pre>
  
  <p><strong>CreateIssueController.java</strong></p>
  
  <pre><code>@Controller
  @SessionAttributes("issuePackage")
  public class CreateIssueController {
  
      @Autowired
      private IssueService issueService;
  
      [...]
  
      @ModelAttribute("issuePackage")
      public IssueTagEnvironment populateNewIssue () {
  
          return new IssueTagEnvironment();
      }
  
      @InitBinder
      public void initBinder (WebDataBinder binder) {
  
          [...]
      }
  
      @RequestMapping(value = "/issues/CreateIssue", method = RequestMethod.GET)
      public ModelAndView createIssueGet (@ModelAttribute("issuePackage") IssueTagEnvironment issuePackage) {
  
          ModelAndView mav = new ModelAndView("/issues/CreateIssue");
  
          [...]
  
          issuePackage.getIssue().setReporter(SecurityUtils.getCurrentUser());
  
          return mav;
      }
  
      @RequestMapping(value = "/issues/CreateIssue", method = RequestMethod.POST)
      public String createIssuePost (@ModelAttribute("issuePackage") IssueTagEnvironment issuePackage,
                                     BindingResult result,
                                     SessionStatus status) {
  
          if (result.hasErrors() == true) {
              return "redirect:/issues/CreateIssue";
          }
  
          [...]
  
          issueService.createIssue(issuePackage.getIssue());
  
          status.setComplete();
          return "redirect:/issues/" + issuePackage.getIssue().getId();
      }
  
  }
  </code></pre>
  
  <p>So far everything seems correct (and in indeed works). But here are the dragons:</p>
  
  <ul>
  <li>I am within an "edit" page changing data from an existing issue.</li>
  <li>Instead of submitting the changes I decide to press the "Go Back" button from the navigator.</li>
  <li>Right after that action (Go Back), I decide to create a new issue and... Here it is! <strong>The form to create a new issue isn't empty but filled with the information of the previous "edited-but-not-submitted" issue.</strong></li>
  </ul>
  
  <p>I understand what the problem is: The <code>controller</code> is not completing the session/status by executing <code>status.setComplete()</code>.</p>
  
  <p>My question here is, how to solve this problem?</p>
  
  <p>Thanks in advance to the community!</p>