Hello,
Im writting a web application using spring frame work where after successful login a dashboard is shown according to user's privilege.all the beans,controller,service & Dataacess are wired with default scope ie singleton. I have extended a abstract controller and code looks like this.
in the success.jsp, all the district and department under his privileges are displayed. how can i make this thread safe as multiple users will be loging in at same time .will there be any problem with thread saftey when i use unsynchronized objects like httpsession and HashMap. I have not synchronized the access of "map" in jsp also . do i need to synchrnize explicitly in all the beans and jsp to achieve thread safety ? Can any one guide me on this ?Code:public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) { Map<String, Object> map = new HashMap<String, Object>(); HashMap userSession = (HashMap) request.getSession().getAttribute("userMap"); String userPrivilege = userSession.get("privileges").toString(); int userId = StringUtilClass.convertToInt(userSession.get("userId").toString()); HashMap<String, List> detailMap = dashboardService.getDetailsofUser(userId); if (detailMap.containsKey("deptartment")) { map.put("deptartment", detailMap.get("deptartment")); } if (detailMap.containsKey("district")) { map.put("district", detailMap.get("district")); } return (new ModelAndView("success", "map", map)); }
thanks
Anuja


Reply With Quote