tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simha, Kailas" <kailas_si...@merck.com>
Subject RE: Accessing Sessions in the container
Date Thu, 02 Oct 2003 20:48:52 GMT
Filip,

I will go with option 1 (how else would I get familiar :)).
Thanks for all your help! Will come back for more !

Kailas
Enterprise Web Infrastructure


-----Original Message-----
From: Filip Hanik [mailto:devlists@hanik.com] 
Sent: Thursday, October 02, 2003 4:42 PM
To: Tomcat Users List
Subject: Re: Accessing Sessions in the container


the code is in the wrong place:

if you don't know what a valve is, you have two options:
1. Read up on it, and configure a valve in server.xml
2. Skip this solution all together (recommended since you are not familiar
with tomcat internals) and go with Yoav's suggestion

Filip

----- Original Message -----
From: "Simha, Kailas" <kailas_simha@merck.com>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Thursday, October 02, 2003 1:37 PM
Subject: RE: Accessing Sessions in the container


Oops ! Here it is:
98:org.apache.catalina.HttpRequest req =
(org.apache.catalina.HttpRequest)request;
99: System.out.println("after the catalina
request");
100: StandardManager manager =
(StandardManager)req.getContext().getManager();
101: Session[] sessions = manager.findSessions();
102:
103: for(int i=0; i<sessions.length;i++)
104: {
105: Session tempSession
= sessions[i];
106:
writer.println(tempSession);
107:
System.out.println("The Session Id is : "+tempSession.getId());
108: }

Kailas
Enterprise Web Infrastructure


-----Original Message-----
From: Filip Hanik [mailto:devlists@hanik.com]
Sent: Thursday, October 02, 2003 4:34 PM
To: Tomcat Users List
Subject: Re: Accessing Sessions in the container


show us line 98 in MyServlet.java:98,
the error you are getting is NOT in the valve,

Filip
----- Original Message -----
From: "Simha, Kailas" <kailas_simha@merck.com>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Thursday, October 02, 2003 1:22 PM
Subject: RE: Accessing Sessions in the container


I am sorry. How do I get the 'real' stack trace?
Thanks for being patient !

Kailas
Enterprise Web Infrastructure


-----Original Message-----
From: Filip Hanik [mailto:devlists@hanik.com]
Sent: Thursday, October 02, 2003 3:59 PM
To: Tomcat Users List
Subject: Re: Accessing Sessions in the container


ok, get us the real stack trace,
this one shows a classcast exception in your code, not in the valve

MyServlet.java:98, hence you have not showed us this code before

Filip
----- Original Message -----
From: "Simha, Kailas" <kailas_simha@merck.com>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Thursday, October 02, 2003 12:54 PM
Subject: RE: Accessing Sessions in the container


Here is the error snippet:
type Exception report

message

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception

java.lang.ClassCastException
at org.apache.catalina.servlets.MyServlet.doGet(MyServlet.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
.................
Thanks !

Kailas
Enterprise Web Infrastructure


-----Original Message-----
From: Filip Hanik [mailto:devlists@hanik.com]
Sent: Thursday, October 02, 2003 3:52 PM
To: Tomcat Users List
Subject: Re: Accessing Sessions in the container


what does your error say?
----- Original Message -----
From: "Simha, Kailas" <kailas_simha@merck.com>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Thursday, October 02, 2003 12:47 PM
Subject: RE: Accessing Sessions in the container


Well,  I have it in the import. But here is the code snippet. Am I doing
anything wrong here? Thanks a lot for your help !

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

org.apache.catalina.HttpRequest req =
(org.apache.catalina.HttpRequest)request;
StandardManager manager = (StandardManager)req.getContext().getManager();
Session[] sessions = manager.findSessions();

}


Kailas
Enterprise Web Infrastructure


-----Original Message-----
From: Filip Hanik [mailto:devlists@hanik.com]
Sent: Thursday, October 02, 2003 3:43 PM
To: Tomcat Users List
Subject: Re: Accessing Sessions in the container


import org.apache.catalina.Session;

that is the Session you will be getting back from findSessions

----- Original Message -----
From: "Simha, Kailas" <kailas_simha@merck.com>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Thursday, October 02, 2003 12:32 PM
Subject: RE: Accessing Sessions in the container


This gives me a class cast exception when running !
Thanks !

Kailas
Enterprise Web Infrastructure


-----Original Message-----
From: Filip Hanik [mailto:devlists@hanik.com]
Sent: Thursday, October 02, 2003 3:05 PM
To: Tomcat Users List
Subject: Re: Accessing Sessions in the container


put a Valve in your context and you can do all kinds of things there

on the invoke you can do

StandardManager manager =
(StandardManager)request.getContext().getManager();
Session[] sessions = manager.findSessions();

the valve if configured only to one context to so you will only get one
manager, ie one webapp

Filip

----- Original Message -----
From: "Tim Funk" <funkman@joedog.org>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
Sent: Thursday, October 02, 2003 11:56 AM
Subject: Re: Accessing Sessions in the container


But that restriction can be bypssed by creating a SessionListener to store
these sessions yourself in ServletContext scope. Search the archive for more
info about this.

Doing so can also easily create a memory leak if one is not careful.

-Tim

Filip Hanik wrote:

> prohibited by spec
>
> Filip
>
> ----- Original Message -----
> From: "Simha, Kailas" <kailas_simha@merck.com>
> To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
> Sent: Thursday, October 02, 2003 11:50 AM
> Subject: Accessing Sessions in the container
>
>
> Hi all,
> How would I be able to access/list all the sessions running on a 
> JVM/Container? Any sample code would be delightfully welcome! Thanks 
> in advance, Kailas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message