0

Actually i am setting the attributes which are getting from bean class in modelandveiw method and trying to get that attribute in other modelandveiw method method but getting null values in

rs.getAttribute("customerId")

. Please help me.

 @RequestMapping(value ="/insert",method= RequestMethod.Post) public ModelAndView inserData(@ModelAttribute SavingBean savingBean,HttpServletRequest rs) { HttpSession session = rs.getSession(); if (savingBean != null) SavingBean saving = persionalService.insertData(savingBean); int a = saving.getCustomerId(); rs.setAttribute("customerId",a ); System.out.println(saving.getDisgnProf()); List<SavingBean> list = new ArrayList<SavingBean>(); list.add(saving); return new ModelAndView("welcome","list", list); } @RequestMapping(value ="/insertdata",method= RequestMethod.Post) public ModelAndView check (@ModelAttribute SavingBean savingBean,HttpServletRequest rs) { System.out.println(savingBean.getFirstName()); HttpSession session = rs.getSession(); System.out.println("abhishek" + rs.getAttribute("customerId")); return null ; 

}

0

2 Answers 2

1

You're not putting or getting anything from the session in this code. You're putting and getting attributes from rs, and rs is the request, not the session.

Sign up to request clarification or add additional context in comments.

Comments

0

Yes you are putting it in the request rs, put it in session instead and you vill se it

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.