0

I have a Portlet controller like this. Here I bind a variable to Session. After that it redirects to another controller and renders the jsp .

@SessionAttributes({"attrName"})
public class Controller{
public void manage(ModelMap modelMap)  {
modelMap.addAttribute("attrName", true)
response.sendRedirect(URL_CONTROLLER_2);
}
}

So this redirects to another controller that renders the jsp. In jsp when I do:

alert("${attrName}")

I get null. Why am I not able to see the attribute. Even when I debug and I check ModelMap in controller # 2, the attribute "attrName" is not present in session.

Victor
  • 16,609
  • 71
  • 229
  • 409

1 Answers1

0

AFAIK it's an expected behaviour because @SessionAttributes are not shared among different controllers. Attributes saved this way will be removed from session as soon as next controller is called.

Waqas
  • 6,812
  • 2
  • 33
  • 50
  • Thanks.but these controllers are sharing same session...so the attributes should remain. Just guessing though. – Victor Feb 23 '12 at 16:35
  • Did you read this: http://claymitchell.net/2008/02/11/spring-framework-annotation-sessionattribute-can-be-confusing/ – Waqas Feb 23 '12 at 16:39