Spring MVC: Possible to submit a form without dependency on HttpSession
Ted Hankey
Greenhorn
Joined: Jun 20, 2010
Posts: 2
posted
0
Hi,
Is it possible to submit a form in a JSP to a Spring Controller without the dependency on a HttpSession?
My Controller is defined as follows, with a load.do GET request and a save.do POST request:
@Controller
@RequestMapping("/optRules")
@SessionAttributes({"optRulesForm", "optDeskForm"})
public class OptRulesController {
.
.
.
@RequestMapping(value = "/load.do")
public ModelAndView getRuleAttributesAndRules(ModelMap model, HttpSession session, @RequestParam
String desk) {
session.setAttribute("desk", desk);
// Logic here to retrieve optRulesForm
model.addAttribute("optRulesForm", optRulesForm);
return new ModelAndView("opt/optRules", model);
}
.
.
.
@RequestMapping(value = "/save.do")
public ModelAndView saveRuleAttributesAndRules(@Valid
@ModelAttribute("optRulesForm")
OptRulesFormDTO optRulesForm, BindingResult bindingResult, HttpSession session, Principal principal, ModelMap model) {
// Logic here to save optRulesForm
model.addAttribute("optRulesForm", optRulesForm);
new ModelAndView("opt/optRules", model);
}
.
.
.
The problem is that I am adding new functionality to an existing application, and the session timeout interval is set to 10 minutes in the web.xml file.
This means that when I attempt to invoke save.do after 10 minutes that I get the following Exception:
HttpSessionRequiredException: Session attribute 'optRulesForm' required - not found in session
Annotating a method with @ModelAttribute will not work either, as I need the OptRulesFormDTO to be populated from the submitted form.
Therefore, I am wondering if it is possible to submit a form once the session has expired? I'd have thought there would be some way to achieve this.