javax.servlet.http.HttpSession Java Examples

The following examples show how to use javax.servlet.http.HttpSession. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DemoServlet.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  try {
    HttpSession session = req.getSession(true);
    Storage storage = (Storage) session.getAttribute(Storage.class.getName());
    if (storage == null) {
      storage = new Storage();
      session.setAttribute(Storage.class.getName(), storage);
    }

    // create odata handler and configure it with EdmProvider and Processor
    OData odata = OData.newInstance();
    ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
    ODataHttpHandler handler = odata.createHandler(edm);
    handler.register(new DemoEntityCollectionProcessor(storage));
    handler.register(new DemoEntityProcessor(storage));
    handler.register(new DemoPrimitiveProcessor(storage));
    
    // let the handler do the work
    handler.process(req, resp);
  } catch (RuntimeException e) {
    LOG.error("Server Error occurred in ExampleServlet", e);
    throw new ServletException(e);
  }
}
 
Example #2
Source File: CarController.java    From product-recommendation-system with MIT License 6 votes vote down vote up
/**
 * 向购物车添加商品
 * @return 购物车页面的视图名称
 */
@RequestMapping(value="/addCar", method = RequestMethod.POST)
public String addCar(Long pid, Integer count, HttpSession session, Map<String, Object> map) {
	// 1.首先获得选中的商品
	Product product = productService.getProductByProductId(pid);
	
	// 2.创建一个购物项,并设置商品的数量,商品的数量,商品的单价
	CartItem cartItem = new CartItem();
	cartItem.setProduct(product);
	cartItem.setCount(count);
	// 注:如果以后要开通优惠券系统,则需要在这里加判断即可
	cartItem.setPrice(product.getSalePrice());
	
	// 3.将该商品的信息放入session中
	Cart cart = (Cart) session.getAttribute("cart");
	if (cart == null) {
		cart = new Cart();
		session.setAttribute("cart", cart);
	}
	
	// 4.将购物项添加进来
	cart.addCart(cartItem);
	
	return "front/car";
}
 
Example #3
Source File: BrowserDetectionFilter.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
  HttpServletRequest httpRequest = (HttpServletRequest) request;
  if (!httpRequest.getRequestURI().startsWith("/api/")
      && !isSupported(httpRequest.getHeader(USER_AGENT_HEADER_NAME))) {
    HttpSession session = httpRequest.getSession();
    if (session.getAttribute(CONTINUE_WITH_UNSUPPORTED_BROWSER_TOKEN) == null) {
      if (request.getParameter(CONTINUE_WITH_UNSUPPORTED_BROWSER_TOKEN) != null) {
        session.setAttribute(CONTINUE_WITH_UNSUPPORTED_BROWSER_TOKEN, true);
      } else {
        httpRequest
            .getRequestDispatcher(UNSUPPORTED_BROWSER_MESSAGE_PAGE)
            .forward(request, response);
        return;
      }
    }
  }

  chain.doFilter(request, response);
}
 
Example #4
Source File: SessionMgr.java    From ranger with Apache License 2.0 6 votes vote down vote up
public CopyOnWriteArrayList<UserSessionBase> getActiveSessionsOnServer() {

		CopyOnWriteArrayList<HttpSession> activeHttpUserSessions = RangerHttpSessionListener.getActiveSessionOnServer();
		CopyOnWriteArrayList<UserSessionBase> activeRangerUserSessions = new CopyOnWriteArrayList<UserSessionBase>();

		if (CollectionUtils.isEmpty(activeHttpUserSessions)) {
			return activeRangerUserSessions;
		}

		for (HttpSession httpSession : activeHttpUserSessions) {

			if (httpSession.getAttribute(RangerSecurityContextFormationFilter.AKA_SC_SESSION_KEY) == null) {
				continue;
			}

			RangerSecurityContext securityContext = (RangerSecurityContext) httpSession.getAttribute(RangerSecurityContextFormationFilter.AKA_SC_SESSION_KEY);
			if (securityContext.getUserSession() != null) {
				activeRangerUserSessions.add(securityContext.getUserSession());
			}
		}

		return activeRangerUserSessions;
	}
 
Example #5
Source File: CustomAuditEventRepositoryIntTest.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddEventWithWebAuthenticationDetails() {
    HttpSession session = new MockHttpSession(null, "test-session-id");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setSession(session);
    request.setRemoteAddr("1.2.3.4");
    WebAuthenticationDetails details = new WebAuthenticationDetails(request);
    Map<String, Object> data = new HashMap<>();
    data.put("test-key", details);
    AuditEvent event = new AuditEvent("test-user", "test-type", data);
    customAuditEventRepository.add(event);
    List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll();
    assertThat(persistentAuditEvents).hasSize(1);
    PersistentAuditEvent persistentAuditEvent = persistentAuditEvents.get(0);
    assertThat(persistentAuditEvent.getData().get("remoteAddress")).isEqualTo("1.2.3.4");
    assertThat(persistentAuditEvent.getData().get("sessionId")).isEqualTo("test-session-id");
}
 
Example #6
Source File: UserController.java    From SimpleBBS with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = "/register.do", method = RequestMethod.POST)
public String register(User user, Invitecode invitecode, @RequestParam(value = "yzm", required = false) String yzm, HttpSession session) {
    if (user.getUname().length() > 16 || user.getUpwd().length() > 16 || user.getUpwd().length() < 6) {
        return "注册失败:用户名或密码长度必须小于16位";
    }

    if (session.getAttribute("yzm").equals(yzm.toLowerCase())) {
        user.setUpwd(DigestUtils.md5DigestAsHex(user.getUpwd().getBytes()));
        user.setLevel(1);
        user.setUcreatetime(new Date());
        user.setUstate(1);
        try {
            userService.register(user, invitecode);
            return "注册成功";
        } catch (MessageException e) {
            return e.getMessage();
        }
    } else
        return "验证码错误";

}
 
Example #7
Source File: TestExtendedResourceFinderAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSearchImageResource_2() throws Throwable {
    this.executeEdit("ART102", "admin");//Contenuto customers
    String contentOnSessionMarker = super.extractSessionMarker("ART102", ApsAdminSystemConstants.EDIT);

    //iniziazione parametri sessione
    HttpSession session = this.getRequest().getSession();
    session.setAttribute(ResourceAttributeActionHelper.ATTRIBUTE_NAME_SESSION_PARAM, "Foto");
    session.setAttribute(ResourceAttributeActionHelper.RESOURCE_TYPE_CODE_SESSION_PARAM, "Image");
    session.setAttribute(ResourceAttributeActionHelper.RESOURCE_LANG_CODE_SESSION_PARAM, "it");

    this.initContentAction("/do/jacms/Content/Resource", "search", contentOnSessionMarker);
    this.addParameter("resourceTypeCode", "Image");//per replicare il chain in occasione dei chooseResource da edit Contenuto.
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);

    ResourceFinderAction action = (ResourceFinderAction) this.getAction();
    assertEquals(3, action.getResources().size());
    assertTrue(action.getResources().contains("82"));
}
 
Example #8
Source File: ConfigAction.java    From Picuang with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/api/admin/import")
@ResponseBody
public Result importConfig(@PathVariable MultipartFile file, HttpSession session) {
    Result result = new Result();
    try {
        String filename = file.getOriginalFilename();
        // 如果已登录 && 文件不为空 && 是ini文件
        if (logged(session) && (!file.isEmpty()) && filename.matches(".*(\\.ini)$")) {
            File config = new File("config.ini");
            config.renameTo(new File("config.ini.backup"));
            File newConfig = new File(config.getAbsolutePath());
            file.transferTo(newConfig);
            Logger.log(newConfig.getPath());
            Prop.reload();
            result.setCode(200);
        } else {
            result.setCode(500);
        }
    } catch (Exception e) {
        e.printStackTrace();
        result.setCode(500);
    }
    return result;
}
 
Example #9
Source File: RecordService.java    From JobX with Apache License 2.0 6 votes vote down vote up
public void getPageBean(HttpSession session, PageBean<Record> pageBean,Record record,boolean status) {
    pageBean.put("record",record);
    pageBean.put("running",status);
    pageBean.put("currTime",new Date());
    if (!JobXTools.isPermission(session)) {
        User user = JobXTools.getUser(session);
        pageBean.put("userId",user.getUserId());
    }
    List<RecordBean> records = recordDao.getByPageBean(pageBean);
    if (CommonUtils.notEmpty(records)) {
        int count = recordDao.getCount(pageBean.getFilter());
        List<Record> recordList = new ArrayList<Record>(0);
        for (RecordBean bean:records) {
            Record item = Record.transfer.apply(bean);
            List<Record> redoList = getRedoList(bean.getRecordId());
            if (CommonUtils.notEmpty(recordList)) {
                item.setRedoList(redoList);
                item.setRedoCount(redoList.size());
            }
            recordList.add(item);
        }
        pageBean.setResult(recordList);
        pageBean.setTotalCount(count);
    }
}
 
Example #10
Source File: AuthServlet.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
private void loginUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
  Map<String, Object> responseData = new HashMap<String, Object>();
  HttpSession session = request.getSession();
  User user = (User) session.getAttribute("user");
  IAuthenticationProvider authenticationProvider = Config.getAuthenticationProvider();
  if(user == null) {
    user = authenticationProvider.login(request);
  }
  if (user == null) {
    responseData.put(LOGIN_STATUS_FIELD, false);
    String form = authenticationProvider.getLoginForm();
    if (form != null) {
      responseData.put(LOGIN_FORM_FIELD, form);
    }
  } else {
    Config.getAuthorizationProvider().setUserSecurityAttributes(user);
    responseData.put(LOGIN_STATUS_FIELD, true);
    responseData.put(USER_FIELD, user);
    session.setAttribute("user", user);
  }

  HttpUtil.sendResponse(response, new ObjectMapper().writeValueAsString(responseData), HttpUtil.JSON);
}
 
Example #11
Source File: MockPageContext.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration<String> getAttributeNamesInScope(int scope) {
	switch (scope) {
		case PAGE_SCOPE:
			return getAttributeNames();
		case REQUEST_SCOPE:
			return this.request.getAttributeNames();
		case SESSION_SCOPE:
			HttpSession session = this.request.getSession(false);
			return (session != null ? session.getAttributeNames() : null);
		case APPLICATION_SCOPE:
			return this.servletContext.getAttributeNames();
		default:
			throw new IllegalArgumentException("Invalid scope: " + scope);
	}
}
 
Example #12
Source File: CustomAuditEventRepositoryIntTest.java    From e-commerce-microservice with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddEventWithWebAuthenticationDetails() {
    HttpSession session = new MockHttpSession(null, "test-session-id");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setSession(session);
    request.setRemoteAddr("1.2.3.4");
    WebAuthenticationDetails details = new WebAuthenticationDetails(request);
    Map<String, Object> data = new HashMap<>();
    data.put("test-key", details);
    AuditEvent event = new AuditEvent("test-user", "test-type", data);
    customAuditEventRepository.add(event);
    List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAll();
    assertThat(persistentAuditEvents).hasSize(1);
    PersistentAuditEvent persistentAuditEvent = persistentAuditEvents.get(0);
    assertThat(persistentAuditEvent.getData().get("remoteAddress")).isEqualTo("1.2.3.4");
    assertThat(persistentAuditEvent.getData().get("sessionId")).isEqualTo("test-session-id");
}
 
Example #13
Source File: AdminController.java    From spring-boot-projects with Apache License 2.0 5 votes vote down vote up
@PostMapping(value = "/login")
public String login(@RequestParam("userName") String userName,
                    @RequestParam("password") String password,
                    @RequestParam("verifyCode") String verifyCode,
                    HttpSession session) {
    if (StringUtils.isEmpty(verifyCode)) {
        session.setAttribute("errorMsg", "验证码不能为空");
        return "admin/login";
    }
    if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
        session.setAttribute("errorMsg", "用户名或密码不能为空");
        return "admin/login";
    }
    String kaptchaCode = session.getAttribute("verifyCode") + "";
    if (StringUtils.isEmpty(kaptchaCode) || !verifyCode.equals(kaptchaCode)) {
        session.setAttribute("errorMsg", "验证码错误");
        return "admin/login";
    }
    Admin adminUser = adminService.login(userName, password);
    if (adminUser != null) {
        session.setAttribute("loginUser", adminUser.getAdminNickName());
        session.setAttribute("loginUserId", adminUser.getAdminId());
        //session过期时间设置为7200秒 即两小时
        //session.setMaxInactiveInterval(60 * 60 * 2);
        return "redirect:/admin/index";
    } else {
        session.setAttribute("errorMsg", "登陆失败");
        return "admin/login";
    }
}
 
Example #14
Source File: AgreementAction.java    From OA with GNU General Public License v3.0 5 votes vote down vote up
public String addAgree() {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session = request.getSession();
		Users user = (Users)session.getAttribute("admin");
		String key;
		
		if(agreement.getId() == null) {
			agreement.setPersonId(user.getPersonid());
			Document document=new Document();
			String temp=user.getAccount()+Constant.agreement;
			document.setTitle(temp);
			document.setDescription(temp);
			key=Persistence.setVariable(agreement);
			document.setTypePersist(key+"|agreement");
			document.setUrl("showAgreement.jsp");
			documentService.addDocument(document, workflowId, user.getId(), null);
//			agreementService.addAgree(agreement);
			System.out.println("add");
		} else {
			agreement.setPersonId(user.getPersonid());
			agreementService.updateAgree(agreement);
			System.out.println("update");
		}
		String hql = "";
		List<Agreement> agreements = agreementService.getAgreementPages((index==0 ? 1 : index), Agreement.class, hql);
		int total = agreementService.getAllAgreements(Agreement.class, hql).size();
		
		request.setAttribute("listAgree", agreements);
		request.setAttribute("currentIndex", (index==0 ?  1 : index ));
		request.setAttribute("totalSize",total);
		
		return "selectAgree";
	}
 
Example #15
Source File: ServletRequestAttributes.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setAttribute(String name, Object value, int scope) {
	if (scope == SCOPE_REQUEST) {
		if (!isRequestActive()) {
			throw new IllegalStateException(
					"Cannot set request attribute - request is not active anymore!");
		}
		this.request.setAttribute(name, value);
	}
	else {
		HttpSession session = obtainSession();
		this.sessionAttributesToUpdate.remove(name);
		session.setAttribute(name, value);
	}
}
 
Example #16
Source File: SSOAgentSessionManager.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static void invalidateSession(HttpSession session) {
    LoggedInSessionBean sessionBean = (LoggedInSessionBean) session.getAttribute(
            SSOAgentConstants.SESSION_BEAN_NAME);
    if (sessionBean != null && sessionBean.getSAML2SSO() != null) {
        String sessionIndex = sessionBean.getSAML2SSO().getSessionIndex();
        if (sessionIndex != null) {
            Set<HttpSession> sessions = ssoSessionsMap.get(sessionIndex);
            sessions.remove(session);
        }
    }
}
 
Example #17
Source File: CollectController.java    From EasyHousing with MIT License 5 votes vote down vote up
@RequestMapping(value="rentHouseCollect.do", method={RequestMethod.GET,RequestMethod.POST})
public ModelAndView collect(HttpServletRequest request) {
	ModelAndView modelAndView = new ModelAndView();
	HttpSession session = request.getSession();
	int rentHouseId = (Integer)session.getAttribute("rentHouseId"); // 获得租房Id
	User user = (User)session.getAttribute("user");
	int userId = user.getUserId();
	rentHouseCollect.insert(userId, rentHouseId);
	session.setAttribute("haveRent", 1); // haveRent记录是否该房子被收藏过,用于页面文本显示判定
	modelAndView.setViewName("rentDetail");
	return modelAndView;
}
 
Example #18
Source File: HttpFlexSession.java    From flex-blazeds with Apache License 2.0 5 votes vote down vote up
/**
 * Implements HttpSessionListener.
 * When an HttpSession is destroyed, the associated HttpFlexSession is also destroyed.
 * NOTE: This method is not invoked against an HttpFlexSession associated with a request
 * handling thread.
 * @param event the HttpSessionEvent
 */
public void sessionDestroyed(HttpSessionEvent event)
{
    HttpSession session = event.getSession();
    Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(session);
    HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.remove(session.getId());
    if (flexSession != null)
    {
        // invalidate the flex session
        flexSession.superInvalidate();

        // Send notifications to attribute listeners if needed.
        // This may send extra notifications if attributeRemoved is called first by the server,
        // but Java servlet 2.4 says session destroy is first, then attributes.
        // Guard against pre-2.4 containers that dispatch events in an incorrect order, 
        // meaning skip attribute processing here if the underlying session state is no longer valid.
        try
        {
            for (Enumeration e = session.getAttributeNames(); e.hasMoreElements(); )
            {
                String name = (String) e.nextElement();
                if (name.equals(SESSION_ATTRIBUTE))
                    continue;
                Object value = session.getAttribute(name);
                if (value != null)
                {
                    flexSession.notifyAttributeUnbound(name, value);
                    flexSession.notifyAttributeRemoved(name, value);
                }
            }
        }
        catch (IllegalStateException ignore)
        {
            // NOWARN
            // Old servlet container that dispatches events out of order.
        }
    }
}
 
Example #19
Source File: ProfileController.java    From blog-spring with MIT License 5 votes vote down vote up
@PostMapping("/change-password")
@ResponseBody
public JSONReplyDTO changePassword(
    HttpSession session,
    @ModelAttribute(name = "currentUser", binding = false) User currentUser,
    @RequestParam String oldPassword,
    @RequestParam String password,
    @RequestParam String passwordConfirmation) {
  if (password == null || password.isEmpty()) {
    return JSONReplyDTO.fail("New password cannot be empty");
  } else if (!password.equals(passwordConfirmation)) {
    return JSONReplyDTO.fail("Password confirmation does not match new password");
  } else if (password.length() < 8) {
    return JSONReplyDTO.fail("New password must not be less than 8 characters");
  } else if (!userService.validatePassword(currentUser, oldPassword)) {
    return JSONReplyDTO.fail("Incorrect password");
  }

  userService.updatePassword(currentUser, password);

  // Must invalidate session (include remember-me token) to apply new password
  session.invalidate();
  SecurityContextHolder.getContext().setAuthentication(null);

  HashMap<String, String> data = new HashMap<>();
  data.put("url", "/login");
  return new JSONReplyDTO(
      0, "Password changed successfully. You need to relogin to apply the new password", data);
}
 
Example #20
Source File: AdminController.java    From bicycleSharingServer with MIT License 5 votes vote down vote up
/**
 * 7.管理员授权处理
 *
 * @param requestMap
 * @param session
 * @param password
 * @return WEB-INF/jsp/admin/admin_list.jsp
 */
@RequestMapping(value = "admin-admin-password-execute", method = RequestMethod.POST)
public String passwordExecute(Map<String, Object> requestMap, HttpSession session,
                              @RequestParam String password) {
    if ("huija".equals(password)) {
        session.setAttribute("advanced", 1);
    }
    return "redirect:/admin-admin-list-show?page=1";
}
 
Example #21
Source File: UserController.java    From SimpleBBS with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/ban/{uid}")
@ResponseBody
public String banUser(@PathVariable Integer uid, HttpSession session) {

    User onlineUser = (User) session.getAttribute("user");
    if (onlineUser == null || onlineUser.getLevel() == 1)
        return "没有权限";
    User user = userService.findUserByUid(uid);
    if (user.getLevel() == 0)
        return "此账号为管理员";
    userService.banUser(user);
    return "禁言成功";
}
 
Example #22
Source File: CookieBasedAuthenticationHandler.java    From product-private-paas with Apache License 2.0 5 votes vote down vote up
private boolean isUserLoggedIn(HttpSession httpSession) {
    String userName = (String) httpSession.getAttribute("userName");
    String tenantDomain = (String) httpSession.getAttribute("tenantDomain");
    Integer tenantId = (Integer) httpSession.getAttribute("tenantId");
    if (userName != null && tenantDomain != null && tenantId != null) {
        return true;
    }
    return false;
}
 
Example #23
Source File: TestBug49158.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void service(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {
    HttpSession session = req.getSession();
    session.invalidate();
    session = req.getSession();
    session.invalidate();
    req.getSession();
}
 
Example #24
Source File: OIDCAuthenticationClient.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public OIDCAuthenticationClient(ConfigurationContext ctx, String serverURL, String cookie,
                                    HttpSession session) throws Exception {
    this.session = session;
    String serviceEPR = serverURL + "OIDCAuthenticationService";
    stub = new OIDCAuthenticationServiceStub(ctx, serviceEPR);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    if (cookie != null) {
        options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
    }
}
 
Example #25
Source File: CustomListener.java    From XRTB with Apache License 2.0 5 votes vote down vote up
@Override
public void sessionCreated(HttpSessionEvent ev) {
	HttpSession session = ev.getSession();
	String id = session.getId();

	sessions.add(session);
	//System.out.println("SESSION: " + id + " was created");
	
}
 
Example #26
Source File: TestTomcat.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws IOException {
    HttpSession s = req.getSession(true);
    s.getId();
    res.getWriter().write("Hello world");
}
 
Example #27
Source File: AttendanceManagementAction.java    From OA with GNU General Public License v3.0 5 votes vote down vote up
public String OnAndOffRegister() {
	List<OnAndOffRegister> listOnAndOffRegisters = attendanceService.getRegisterSet();
	
	HttpServletRequest request = ServletActionContext.getRequest();
	HttpSession session = request.getSession();
	request.setAttribute("onTime", listOnAndOffRegisters.get(0).getRegularTime());
	request.setAttribute("offTime", listOnAndOffRegisters.get(1).getRegularTime());
	Users user = (Users)session.getAttribute("admin");
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	String date = sdf.format(new Date());
	
	System.out.println("date is "+date);
	List<UserOnAndOffRegister> userOnAndOffRegisterList = attendanceService.select(user.getId(),date);
	System.out.println("userONandoff list size is "+userOnAndOffRegisterList.size());
	if(userOnAndOffRegisterList.size() != 0) {
		if(userOnAndOffRegisterList.get(0).getOnTime() == null &&
		   userOnAndOffRegisterList.get(0).getOffTime() != null) {
			request.setAttribute("hasClickedOff", "hasClicked");
			return "OnAndOffRegister";
		} 
		if(userOnAndOffRegisterList.get(0).getOnTime() != null &&
		   userOnAndOffRegisterList.get(0).getOffTime() == null) {
			request.setAttribute("hasClickedOn", "hasClicked");
			return "OnAndOffRegister";
		}
		if(userOnAndOffRegisterList.get(0).getOnTime() != null &&
		   userOnAndOffRegisterList.get(0).getOffTime() != null) {
			request.setAttribute("hasClickedOff", "hasClicked");
			request.setAttribute("hasClickedOn", "hasClicked");
			return "OnAndOffRegister";
		}
	} 
	
	return "OnAndOffRegister";
}
 
Example #28
Source File: ApplicationContextHolder.java    From elastic-rabbitmq with MIT License 5 votes vote down vote up
/**
 * @param tenantId
 * @param httpSession
 */
public static void addSession(Integer tenantId, HttpSession httpSession) {
    if (!httpSessions.containsKey(tenantId)) {
        httpSessions.put(tenantId, new HashSet<HttpSession>());
    }

    httpSessions.get(tenantId).add(httpSession);
}
 
Example #29
Source File: ClusterController.java    From kafka-eagle with Apache License 2.0 5 votes vote down vote up
/** Cluster viewer. */
@RequestMapping(value = "/cluster/multi", method = RequestMethod.GET)
public ModelAndView clustersView(HttpSession session) {
	ModelAndView mav = new ModelAndView();
	mav.setViewName("/cluster/multicluster");
	return mav;
}
 
Example #30
Source File: MySessionContext.java    From HomeApplianceMall with MIT License 5 votes vote down vote up
public static synchronized HttpSession getSession(String session_id) {
    if (session_id == null){
    	return null;
    }else{
    	return mymap.get(session_id);
    }
}