Hi Fotis, hi all

Following previous suggestion, I have been trying with session filters like the 
following example:

import java.io.IOException;
import java.util.Date;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class LoginFilter implements Filter {

        public void doFilter(ServletRequest req, ServletResponse res,
                        FilterChain chain) throws IOException, ServletException 
{

                HttpServletRequest request = (HttpServletRequest) req;

                //Get the IP address of client machine.
                String ipAddress = request.getRemoteAddr();

                //Log the IP address and current timestamp.
                System.out.println("IP "+ipAddress + ", Time "
                                                        + new 
Date().toString());

                chain.doFilter(req, res);
        }
        public void init(FilterConfig config) throws ServletException {

                //Get init parameter
                String testParam = config.getInitParameter("test-param");

                //Print the init parameter
                System.out.println("Test Param: " + testParam);
        }
        public void destroy() {
                //add code to release any resource
        }
}

The filter works OK having being mapped in the WEB.XML as:

<!-- **************************************************** -->
<filter>
        <filter-name>loginFilter</filter-name>
        <filter-class>
                myPackage.filters.LoginFilter
        </filter-class>
        <init-param>
                <param-name>test-param</param-name>
                <param-value>This parameter is for testing.</param-value>
        </init-param>
</filter>
<filter-mapping>
        <filter-name>loginFilter</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>
<!-- **************************************************** --> 
I suppose any request from client would generate a call to this filter. (Well, 
any but my Flex client app served by the same servlet container the filter 
resides)

Unfortunatelly this can't trap the FLEX client application initial login 
session to Tomcat. 
The setup here is a typical FLEX 3 client to a Tomcat servlet container backend 
and BlazeDS. This client uses AMF channel and RPC to communicate with HSQLDB 
through BlazeDS. (I believe this is quite a typical setup).

Is there any more definite example/guidance or reading material to my original 
question? Any help is greatly appreciated.

Thanks all
George

--- In [email protected], Fotis Chatzinikos <fotis.chatzini...@...> 
wrote:
>
> Hi George,
> 
> I have not touched session persistence in my installation - so if enabled by
> default you can leave it as is..
> 
> On Thu, Jan 21, 2010 at 4:11 PM, GeorgeB <grg_b...@...> wrote:
> 
> >
> >
> >
> > Hi Fotis,
> >
> > One relative question about using sessions:
> > Should in this case the persistent storage of the context be disabled in
> > Tomcat 6.0? (This is enabled by default)
> >
> > Thanks
> > George
> >
> >
> > --- In [email protected] <flexcoders%40yahoogroups.com>, Fotis
> > Chatzinikos <fotis.chatzinikos@> wrote:
> > >
> > > If you are using sessions you can add a session destroy filter in tomcat
> > > that retrieves the user id from the session and updates the db that the
> > user
> > > has logged out - that will work - the only problem is that if you use a
> > long
> > > session timeout your db field will be updated at the end of this
> > period...
> > >
> > > On Thu, Jan 21, 2010 at 11:14 AM, GeorgeB <grg_blls@> wrote:
> > >
> > > >
> > > >
> > > > Hi all,
> > > >
> > > > I think it has been asked before but I don't recall any answer as this
> > is:
> > > > 1. Not a Flex directly related issue,
> > > > 2. Not even a BlazeDS issue per se,
> > > >
> > > > My client-server application depends on a Flex client and a Tomcat +
> > > > BlazeDS + MySQL + Hibernate backend server. It tracks whether a user is
> > > > logged in by keeping a "InSession" boolean field in the database.
> > > > This "InSession" starts the session clock by the time the user has
> > properly
> > > > logged in and stops by the time he has properly logged out by "Exit"
> > the
> > > > app.
> > > > Then the database is updated and that user is marked as
> > "InSession=false",
> > > > while that session has been timed.
> > > >
> > > > But if the communication channel goes down (Internet, LAN, etc), or the
> > > > client's browser is inadvertently force closed, the database loses
> > > > track/sync of the user and keeps reporting as "InSession=true", while
> > > > session time keeps running indefinately.
> > > >
> > > > What I need is a server side procedure that:
> > > > 1. Either catch an exception on losing connection event, or
> > > > 2. in a continuous loop scans for connected users (out of a list of
> > > > "InSession=true")
> > > >
> > > > Obviously losing the client-server connection is a very generalized
> > problem
> > > > to track and needs more specific solutions. I am not sure if this can
> > be
> > > > solved in BlazeDS level, or I have to go to WEB server sockets. But may
> > I
> > > > ask if anyone has a suggestion, or some relevant documentation for me
> > to
> > > > study?
> > > >
> > > > Thanks all
> > > > George
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Fotis Chatzinikos, Ph.D.
> > > Founder,
> > > LivinData Technologies
> > > www.styledropper.com
> > > Fotis.Chatzinikos@,
> > >
> >
> >  
> >
> 
> 
> 
> -- 
> Fotis Chatzinikos, Ph.D.
> Founder,
> LivinData Technologies
> www.styledropper.com
> fotis.chatzini...@...,
>


Reply via email to