[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [equinox-dev] HttpService, Jetty, Session timeout

Hi again,
thanks for your answers to my question. Seems to be correct that there isn't a system property for setting a global session timeout. I was only thinking about that since we only have to deal with on servlet in RAP.
The code snippet of Ben brought me to the idea of a solution in the Activator of org.eclipse.equinox.http.jetty:

  public void start(BundleContext context) throws Exception {
    server = new HttpServer();
    SocketListener httpListener = createHttpListener(context);
    if (httpListener != null) {
    SocketListener httpsListener = createHttpsListener(context);
    if (httpsListener != null) {
    ServletHandler servlets = new ServletHandler();
    ServletHolder holder
      = servlets.addServlet("/*", InternalHttpServiceServlet.class.getName());
    HttpContext httpContext = createHttpContext(context);

    // read session timeout property something like this
    int sessionTimeout = -1;
    String sessionTimeoutProperty
      = context.getProperty( "org.osgi.service.http.sessiontimeout" );
    if( sessionTimeoutProperty != null ) {
      try {
        sessionTimeout = Integer.parseInt( sessionTimeoutProperty );
        servlets.setSessionInactiveInterval( sessionTimeout );
      } catch (NumberFormatException e) {
        //(log this) ignore and use default


This would work like the system property used to set the port. Setting the timeouts for each servlet would need a different solution. I'm not quite sure if this would be conform to the servlet specification anyway, since a deployment descriptor defines a session timeout per webapp and not per servlet. At least I think this makes sense since requests to different servlets can be done in one and the same session. Maybe it would be better to set the session timeout per context, but looking at the implementation I wonder if there is really a strict separation between the contexts?

Von: equinox-dev-bounces@xxxxxxxxxxx [mailto:equinox-dev-bounces@xxxxxxxxxxx] Im Auftrag von Jeremy Volkman
Gesendet: Montag, 12. Februar 2007 20:22
An: Equinox development mailing list
Betreff: Re: [equinox-dev] HttpService, Jetty, Session timeout


I don't quite understand the solution that you have in mind.  We set the timeout value on a per-Servlet basis (using the reflection code that Ben posted).  Does your solution support this, or is it an HttpService-global setting?


On 2/12/07, Simon Kaegi <simon.kaegi@xxxxxxxxx> wrote:
Hi Frank and Ben,

Please create an enhancement request in bugzilla.
This could be added to the ServletHandler when the Jetty Server instance is
being created very easily.


----- Original Message -----
From: "Benjamin Schmaus" <benjamin.schmaus@xxxxxxxxx>
To: "Equinox development mailing list" <equinox-dev@xxxxxxxxxxx >
Sent: Monday, February 12, 2007 1:32 PM
Subject: Re: [equinox-dev] HttpService, Jetty, Session timeout

> Hi Frank -
> I've run into this issue before.  Since the OSGi HTTP service doesn't
> support the use of a web.xml file (to the best of my knowledge
> anyway), session timeouts can't be set in the standard way.
> What I've done to work around this is to use reflection to invoke a
> Jetty-specific method for setting session timeouts.
> For example:
>    public void setSessionTimeout(HttpServlet servlet, int timeoutSeconds)
> {
>        ServletContext sc = servlet.getServletContext();
>        Object handler = reflector.invokeMethod(sc,
> "getServletHandler", null, null);
>        reflector.invokeMethod(
>                handler,
>                "setSessionInactiveInterval",
>                new Class[]{Integer.TYPE},
>                new Object[]{new Integer(timeoutSeconds)}
>        );
>    }
> (The 'reflector' object uses the java.lang.reflect API under the hood.)
> AOP might be another approach to setting session timeout under Jetty
> that's worth investigating.
> - Ben
> On 2/12/07, Frank Appel < fappel@xxxxxxxxxxxxxx> wrote:
>> Hi,
>> I've been looking a while for a possibility to set the session timeout of
>> the HttpService using Jetty as the underlying engine. Is there a simple
>> system property like org.osgi.service.http.port which is used to set the
>> port and if so, where can I find documentation about the available
>> properties?
>> Thanks
>> Frank Appel
>> _______________________________________________
>> equinox-dev mailing list
>> equinox-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev

equinox-dev mailing list