Can you set maxprocess=1 in web application server configuration file? John H. Xu
http://www.usanalyst.com http://www.GetusJobs.com (The largest free job portal in North America) ----- Original Message ----- From: "Rick Reumann" To: "Struts Users Mailing List" Subject: probably a cleaner way... testing for just one user Date: Tue, 26 Jul 2005 17:06:32 -0400 > > I have an odd requirement where this internal application should > only be used by one valid user(one session) at a time. (The data > being worked with in the application would require so many locks > that's it just easier to restrict it to one user). Currently I'm > achieving this in the following manner and wondering if there is a > better way to do it... > > 1) A SessionListener ... > > in sesionCreated(..)... > > HttpSession session = event.getSession(); > ServletContext context = session.getServletContext(); > synchronized( context ) { > if ( context.getAttribute(Constants.APPLICATION_IN_USE) == null ) { > //mark it now in use for application scope for any new sessions > to see it's in use > context.setAttribute(Constants.APPLICATION_IN_USE, Boolean.TRUE ); > //but mark in not in use for this session > session.setAttribute(Constants.APPLICATION_IN_USE, Boolean.FALSE); > } else { > //is in use so mark it in use so Session in filter can see it's > being used already > session.setAttribute(Constants.APPLICATION_IN_USE, Boolean.TRUE); > } > } > > sessionDestroyed clears out context APPPLICATION_IN_USE flag. > > > 2) In my servlet filter that filters all requests... > > if ( path.indexOf("/appinuse.jsp") == -1 ) { > if ( session.getAttribute(Constants.APPLICATION_IN_USE) != null > && > ((Boolean)session.getAttribute(Constants.APPLICATION_IN_USE)).booleanValue() ) > { > log.debug("Application already in use!!!"); > response.sendRedirect(contextPath+"/appinuse.jsp"); > return; > } > } > > > Does the above seem to be an ok way to handle this? It's working > but not sure if there is a cleaner way? > > > -- Rick > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] Jack H. Xu Technology columnist and editor http://www.usanalyst.com http://www.getusjobs.com (The largest free job portal in North America) -- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm