RE: How to keep track of sessions
Hi, Mark. To give my own 2 cents, I use a session listener for exactly the same issue: Get information how many sessions are active, who is logged on etc. Currently my application struggles with a memory leak, and I suspect the vector not being cleaned up thoroughly (my problem :-( ). Hiran - Hiran Chaudhuri SAG Systemhaus GmbH Elsenheimerstraße 11 80687 München Germany [EMAIL PROTECTED] Phone +49-89-54742-134 Fax +49-6151-9234-5134 -Original Message- From: Mark O'Driscoll [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 3:21 PM To: Tomcat Users List Subject: Re: How to keep track of sessions I am using the sessions to keep track of who is logged on, for how long and what they have done. Obviously there are other non servlet ways to do this but as tomcat gives the opportunity to track sessions, I thought I'd use it. Session persistence highlights a 'hole' in the sessionListener interface. BTW: I'm surprised you think sessions should not be persisted. I think it's cool! Thanks for the help. - Original Message - From: Shapira, Yoav [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 2:17 PM Subject: RE: How to keep track of sessions Howdy, Sessions are not meant to be persisted across server restarts. Obviously other people have other opinions about that. Which is why I still suggested a solution I've used in the past ;) Even though I disagree with the approach of persisting someone else's proprietary internal objects, I assume that whoever asked the question has a reasonable and well-thought out cause, so I try to help. I'm still unclear as to why one would want to save the session object itself, as opposed to only the parts of interest from it. Does it have to do with load-balancing, wanting to somehow augment / superimpose on the built-in mechanism? Yoav Shapira Millennium ChemInformatics -- -- This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. -- -- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to keep track of sessions
You could use an application context listener to write out the sessions when the context is shutdown and reread them when it starts up. I tried to work out how the manager application (part of the distribution) worked (as it knows about sessions), but gave up as it looked like to much work and too much poking about inside tomcat. for my tastes (which didn't include Mark O'Driscoll wrote: I am trying to keep track of the current sessions that are active in my web application. I have a HttpSessionListener that is correctly called on sessionCreated/sessionDeleted. I keep a reference to each session in the servletContext as a Vector. If tomcat is restarted then the sessions are persisted fine. However my vector of sessions is lost so I have no record of sessions that were created during a previous tomcat run. Any idea how I could find or keep the list of previously created sessions? Is there any way I can find a list of the current sessions without keeping a list (that would be my preference) TIA - Mark -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How to keep track of sessions
Hi, So my first question is, why? If you could describe the motivation / requirements / goals for your need to keep track of all the sessions, perhaps someone could suggest an alternative approach. If tomcat is restarted then the sessions are persisted fine. However my vector of sessions is lost so I have no record of sessions that were created during a previous tomcat run. Any idea how I could find or keep the list of previously created sessions? Sessions are not meant to be persisted across server restarts. Perhaps you are only interested in specific attributes of the sessions? In that case, the Singleton pattern comes to mind to be used as follows: - Have an object, MySessionInfoHolder, that holds the stuff you need about the session, for example some attributes. You probably do *not* want to keep the session ID. - Have a singleton, MySessionInfoManager, that keeps a set (no duplicates) of these MySessionInfoManager objects. - Your session listener (either a Session or a SessionAttribute listener, or both) would extract the proper info from a Jakarta session object and store it in the manager. - On context shutdown, persist the stuff in MySessionInfoManager using castor (or any of the other similar packages) or your own serialization / XML / JDBC / whatever mechanism. - On context startup, recall the stuff from XML / the database / wherever into the manager. Would that approach work for your needs? Yoav Shapira Millennium ChemInformatics This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How to keep track of sessions
Howdy, Sessions are not meant to be persisted across server restarts. Obviously other people have other opinions about that. Which is why I still suggested a solution I've used in the past ;) Even though I disagree with the approach of persisting someone else's proprietary internal objects, I assume that whoever asked the question has a reasonable and well-thought out cause, so I try to help. I'm still unclear as to why one would want to save the session object itself, as opposed to only the parts of interest from it. Does it have to do with load-balancing, wanting to somehow augment / superimpose on the built-in mechanism? Yoav Shapira Millennium ChemInformatics This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to keep track of sessions
I am using the sessions to keep track of who is logged on, for how long and what they have done. Obviously there are other non servlet ways to do this but as tomcat gives the opportunity to track sessions, I thought I'd use it. Session persistence highlights a 'hole' in the sessionListener interface. BTW: I'm surprised you think sessions should not be persisted. I think it's cool! Thanks for the help. - Original Message - From: Shapira, Yoav [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 2:17 PM Subject: RE: How to keep track of sessions Howdy, Sessions are not meant to be persisted across server restarts. Obviously other people have other opinions about that. Which is why I still suggested a solution I've used in the past ;) Even though I disagree with the approach of persisting someone else's proprietary internal objects, I assume that whoever asked the question has a reasonable and well-thought out cause, so I try to help. I'm still unclear as to why one would want to save the session object itself, as opposed to only the parts of interest from it. Does it have to do with load-balancing, wanting to somehow augment / superimpose on the built-in mechanism? Yoav Shapira Millennium ChemInformatics This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How to keep track of sessions
Hi, I like this thread as a theoretical discussion, so let's pursue it a bit more ;) Depending on the kind of information you want to display it gets at sime point annoying to to copy everthing from the session to a store and to remove it from the store when the session ends. - More code = more possible error, less perfomance - More memory = less performance More code, yes. But I think the SessionInfo-type objects would be trivial. The manager would be very easy to write as well. As they are simple and completely under your control, you could make the processing and persistence operations very fast. Having tried that approach on long-running servers with many users and delayed session expiration (120min), leading to many SessionInfo objects that had to be persisted on context shutdown and restored on context startup, I can safely say that performance was not a problem for us. Even for thousands of SessionInfo object, the persistence operations were only a few seconds. And that's on a fairly small server box, JDK 1.2.2 without much tuning. (Although it was a custom SAXParser and not Castor, as I suggested before. Would've been nice to compare them ;)). Even if you do it, the problem of the original poster is the same. Now he has a Vector of SessionInfo I agree. You have to worry about persistence either way. However, persisting your own objects is typically a lot easier than persisting third party objects such as tomcat's session implementation. The part that I think makes his use-case very interesting and non-trivial is the requirement to record (and thus persist) the user's click-stream. I'm not sure off the top of my head how that fits into the SessionInfo object, except maybe as a list of URLs the user visited? We did not have this requirement in the aforementioned system, and so I can't speak to it... I'd be interested to hear from the original poster when a solution is implemented and tested... Yoav Shapira Millennium ChemInformatics This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to keep track of sessions
This is all very interesting but. The sessions are currently persisted or serialized on tomcat exit, fine. I have a collection of session object references. If I save the references they will be invalid when tomcat starts up. If I save (serialize) the objects then I am duplicating what tomcat does. In either case, it's an arse. Am I missing something... - Mark - Original Message - From: Shapira, Yoav [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 3:05 PM Subject: RE: How to keep track of sessions Hi, I like this thread as a theoretical discussion, so let's pursue it a bit more ;) Depending on the kind of information you want to display it gets at sime point annoying to to copy everthing from the session to a store and to remove it from the store when the session ends. - More code = more possible error, less perfomance - More memory = less performance More code, yes. But I think the SessionInfo-type objects would be trivial. The manager would be very easy to write as well. As they are simple and completely under your control, you could make the processing and persistence operations very fast. Having tried that approach on long-running servers with many users and delayed session expiration (120min), leading to many SessionInfo objects that had to be persisted on context shutdown and restored on context startup, I can safely say that performance was not a problem for us. Even for thousands of SessionInfo object, the persistence operations were only a few seconds. And that's on a fairly small server box, JDK 1.2.2 without much tuning. (Although it was a custom SAXParser and not Castor, as I suggested before. Would've been nice to compare them ;)). Even if you do it, the problem of the original poster is the same. Now he has a Vector of SessionInfo I agree. You have to worry about persistence either way. However, persisting your own objects is typically a lot easier than persisting third party objects such as tomcat's session implementation. The part that I think makes his use-case very interesting and non-trivial is the requirement to record (and thus persist) the user's click-stream. I'm not sure off the top of my head how that fits into the SessionInfo object, except maybe as a list of URLs the user visited? We did not have this requirement in the aforementioned system, and so I can't speak to it... I'd be interested to hear from the original poster when a solution is implemented and tested... Yoav Shapira Millennium ChemInformatics This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to keep track of sessions
Hi Can some one provide with some java code where in they have used HttpSessionListener, and then stored the sessions in a vector when a new session is created, and remove it when it is invalidated. i m developing a webapplication where in the database is as400, so when ever a user logs in a job is run on as/400, but if the user just closes the browser without signing out, then this job runs on as/400 untill i restart tomcat, so i would like to know when the user closes the browser, but there is no way i can find it out, so i think i will store all the sessions created in a vector, and when the user signoff I will remove the session from vector and then also run schedule job say after 30 min which will check the session from the vector,to find when was it used last time, and if it is more then some time say 30 min, invalidate that session, which will stop the job running on as400 is there a better way of doing it.. Ashish --- Mark O'Driscoll [EMAIL PROTECTED] wrote: I am trying to keep track of the current sessions that are active in my web application. I have a HttpSessionListener that is correctly called on sessionCreated/sessionDeleted. I keep a reference to each session in the servletContext as a Vector. If tomcat is restarted then the sessions are persisted fine. However my vector of sessions is lost so I have no record of sessions that were created during a previous tomcat run. Any idea how I could find or keep the list of previously created sessions? Is there any way I can find a list of the current sessions without keeping a list (that would be my preference) TIA - Mark -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to keep track of sessions
Is this a bug in tomcat 4.0.4? Notice that these two errors that am posting are from two different applications in the same context. Please help. Thanks. Apache Tomcat/4.0.4 - HTTP Status 500 - Internal Server Error type Exception report message Internal Server Error description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.lang.NullPointerException at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471) at org.apache.jsp.inbox$jsp._jspService(inbox$jsp.java:1043) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:368) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:458) at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:551) at java.lang.Thread.run(Thread.java:536) root cause java.lang.Exception: java.lang.NullPointerException at org.apache.jsp.inbox$jsp._jspService(inbox$jsp.java:1032) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at