I need help. I am working on a project where I have multiple pages and multiple forms; each page has one form. I just need to be able to pass values from one jsp to another.
You could also use session attributes, either manually, such as:
public ModelAndView handleRequest(HttpServletRequest request){
request.getSession().getAttribute("nameOfAttribute");
}
Apologies for writing this as an annotated controller, I do not recall if xml config controllers offer this feature...
There is no Spring code involved for that. The other option is to use the @SessionAttribute annotation on your controller:
@Controller
@SessionAttributes("nameOfAttribute")
public class MyController{
//your session attribute can be accessed in controller methods using @ModelAttribute
public ModelAndView handleRequest(@ModelAttribute("nameOfAttribute")){
session.getAttribute("nameOfAttribute");
}
Note
You will need to clear the session attribute when you are done with it:
request.getSession().setAttribute("nameOfAttribute", null);