Re: getting current context

2011-05-19 Thread Mateu Yabar
Sorry! It is working. I was just looking to another webbap path. So this is the solution: ObjectName name=new ObjectName("Catalina:type=Manager,path=/NAME_OF_APP,host=localhost"); ManagementFactory.getPlatformMBeanServer().getAttribute(name, "activeSessions"); However, is there any way to know wh

Re: getting current context

2011-05-19 Thread Mark Thomas
On 19/05/2011 15:24, Mateu Yabar wrote: > What I have for now, after enableing JMX as descrived in > http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html > > I have the following code: > ObjectName name=new > ObjectName("Catalina:type=Manager,path=/test,host=localhost"); > ManagementFactory.get

Re: getting current context

2011-05-19 Thread Mateu Yabar
What I have for now, after enableing JMX as descrived in http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html I have the following code: ObjectName name=new ObjectName("Catalina:type=Manager,path=/test,host=localhost"); ManagementFactory.getPlatformMBeanServer().invoke(name, "listSessionIds", n

Re: getting current context

2011-05-19 Thread chris derham
On Thu, May 19, 2011 at 10:33 AM, Mateu Yabar wrote: > After all day working on this, I'm still unable to use JMX to obtain the > context. > Please, can anyone gime me a hand? > Obviously if you have spent all day on it, you must have a lot of code. Just send the latest piece, with a description

Re: getting current context

2011-05-19 Thread Mateu Yabar
After all day working on this, I'm still unable to use JMX to obtain the context. Please, can anyone gime me a hand? Thanks! On 19 May 2011 13:12, Mateu Yabar wrote: > > > > 2. The OP wants current sessions so a ServletContextListener that only > > runs at context start and stop isn't going to

Re: getting current context

2011-05-19 Thread Mateu Yabar
> > 2. The OP wants current sessions so a ServletContextListener that only > runs at context start and stop isn't going to help. > In ServletContextListener, arg0.getServletContext(), only gives a ApplicationContextFacade, but I can access apache context from there, so I can't get the active sessi

Re: getting current context

2011-05-19 Thread Mark Thomas
On 19/05/2011 11:17, chris derham wrote: >> >> >> 2. The OP wants current sessions so a ServletContextListener that only >> runs at context start and stop isn't going to help. >> > > I don't understand this - could you explain a little further, or point me to > some docs? I thought when a context

Re: getting current context

2011-05-19 Thread chris derham
> > > 2. The OP wants current sessions so a ServletContextListener that only > runs at context start and stop isn't going to help. > I don't understand this - could you explain a little further, or point me to some docs? I thought when a context starts, sessions can start against it. How is this n

Re: getting current context

2011-05-19 Thread Mateu Yabar
Thanks! I'm looking through JMX (I don't nothing about it), but meanwhile, can anyone tell me how to access the Context through JMX? On 19 May 2011 11:41, Mark Thomas wrote: > On 19/05/2011 10:36, Micka wrote: > > Hi, > > > > You should implents ServletContextListener to get the context () : >

Re: getting current context

2011-05-19 Thread Mark Thomas
On 19/05/2011 10:36, Micka wrote: > Hi, > > You should implents ServletContextListener to get the context () : > > http://www.roseindia.net/servlets/ServletContextListener-example.shtml > > @Override > public void contextInitialized(ServletContextEvent arg0) { > if (context == nu

Re: getting current context

2011-05-19 Thread Mark Thomas
On 19/05/2011 10:30, Mateu Yabar wrote: > Hi to all, > > I need to obtain the number of active sessions on the current application. > If written the following (import org.apache.catalina.Context, import > org.apache.catalina.Manager): > public int getActiveSession(){ > Context context=null; > Mana

Re: getting current context

2011-05-19 Thread Micka
Hi, You should implents ServletContextListener to get the context () : http://www.roseindia.net/servlets/ServletContextListener-example.shtml @Override public void contextInitialized(ServletContextEvent arg0) { if (context == null) { context = arg0.getServletContext()

getting current context

2011-05-19 Thread Mateu Yabar
Hi to all, I need to obtain the number of active sessions on the current application. If written the following (import org.apache.catalina.Context, import org.apache.catalina.Manager): public int getActiveSession(){ Context context=null; Manager manager=context.getManager(); return manager.getActi