Hi,
Am 16.03.2012 um 14:44 schrieb Michiel Vermandel:
> Hi,
>
> Thank you, I saw that section but did not understand that
> javax.servlet.http.HttpSessionListener is a service you can register on.
No, your class must implement the HttpSessionListener and be registered as such:
ServiceRegistration reg =
context.registerService(HttpServiceListener.class.getName(), listener, null);
Regards
Felix
> Do you mean something like this?:
>
> public void start(BundleContext context) throws Exception {
> ServiceReference<HttpSessionListener> sRefL =
> context.getServiceReference(HttpSessionListener.class);
> if (sRefL != null) {
> listener = (HttpSessionListener) context.getService(sRef);
> System.out.println("HttpSessionListener class: " +
> listener.getClass().getName());
> }
> else
> {
> System.out.println("No HttpSessionListener!");
> }
> }
>
>
>
> This gives me "No HttpSessionListener!".
> Do you have a small example?
>
> Thanks
>
>
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials
>
>
> ________________________________
> From: Felix Meschberger <[email protected]>
> To: "[email protected]" <[email protected]>; Michiel Vermandel
> <[email protected]>
> Sent: Friday, March 16, 2012 2:02 PM
> Subject: Re: Getting sessions inside Servlet.
>
> Hi,
>
> Have you consulted [1] ?
>
> So you just register a SessListener service and you should get notified.
>
> Regards
> Felix
>
> [1]
> http://felix.apache.org/site/apache-felix-http-service.html#ApacheFelixHTTPService-ServletAPIEvents
>
> Am 16.03.2012 um 13:51 schrieb Michiel Vermandel:
>
>> Hi,
>>
>> I would like to have a sessionlistener inside a servlet that informs that
>> servlet of sessions being created - or destroyed.
>> Preferably I'd only like to receive the event when the session has requested
>> the servlet.
>>
>> Is this possible with this setup:
>>
>> g! [INFO] Started jetty 6.1.x at port(s) HTTP:8080
>>
>>
>> START LEVEL 1
>> ID|State |Level|Name
>> 0|Active | 0|System Bundle (4.0.2)
>> 1|Active | 1|Apache Felix Bundle Repository (1.6.6)
>> 2|Active | 1|Apache Felix Gogo Command (0.12.0)
>> 3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
>> 4|Active | 1|Apache Felix Gogo Shell (0.10.0)
>> 6|Active | 1|Apache Felix Http Bundle (2.2.0)
>>
>> AND
>>
>> a web.xml like the bridge example?
>> http://svn.apache.org/repos/asf/felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/web.xml
>>
>>
>> Thanks a lot!
>>
>>
>> -----------------
>> http://www.codessentials.com - Your essential software, for free!
>> Follow us at http://twitter.com/#!/Codessentials
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]