Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:27:58+00:00 2026-06-06T13:27:58+00:00

I’m working on GWT. In my application I want to add a session time

  • 0

I’m working on GWT. In my application I want to add a session time out after 2 minutes when no action is performed (including mouse events).

I wrote a class in which I used a GWT session object.

public static boolean ValidSession(HttpSession session) {

        boolean aResult = true;

        logger.debug("Start of ValidSession");
        try
        {
            if(session!=null )
            {
                String strUserInf="";
                strUserInf=(String)session.getAttribute("userInf");
                logger.debug("User Inf in session is: " + strUserInf);
                if(strUserInf==null || strUserInf.trim().equals(""))
                {
                    logger.debug("User Info blank");
                    aResult =false;
                }

            }
            else
            {
                logger.debug("SessionNull");
                aResult=false;
            }
        }
        catch (Exception e) 
        {
            logger.error("Exception in ValidSession: ", e);
            aResult = false;                        
        }
        logger.debug("End of isSessionValid");
        return aResult;
    }

    public static void TimeUpdate(HttpSession session){
        session.setAttribute("lastAccessed", String.valueOf(session.getLastAccessed()));
        System.out.println("lastAccessed "+ session.getAttribute("lastAccessed"));
       }

But it resets the timer only on RPC call. I want to detect mouse movements as well.

Can anyone suggest a solution? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:28:00+00:00Added an answer on June 6, 2026 at 1:28 pm

    You can do code something like this on on module load.

    Create one timer which is running every 2 minute and set session expire flage:

        private static Timer SESSION_TIMER = new Timer() {
                public void run() {
                    SessionFactory.putValue(SesisonKey.SESSION_EXPIRED,
                            true);
                }
            };
    

    call this method for Renew the timer session as below in on module load using this method:

        public static void renewTimer() {
                if (CLIENT_SIDE_TIMER != null) {
                    CLIENT_SIDE_TIMER.cancel();
                    SessionFactory.getClientInstance().put(
                            SesisonKey.SESSION_EXPIRED, false);
                    //CLIENT_SIDE_TIMER.schedule(250 * 60 * 20);
                    //1 Minute = 60000 Milliseconds
                    CLIENT_SIDE_TIMER.schedule(60000 * 2);
                }
            }
    

    NativePreviewHandler handler catch on mouse event and check that session is expired or not flag.

     final NativePreviewHandler nativeHandler = new NativePreviewHandler() {
                        @Override
                        public void onPreviewNativeEvent(NativePreviewEvent event) {
    
                        preventBack();
    
                            if (SessionFactory
                                    .getValue(SesisonKey.CLIENT_SESSION_EXPIRED) != null) {
                                boolean expire = (Boolean) SessionFactory
                                        .getValue(SesisonKey.CLIENT_SESSION_EXPIRED);
                                if (expire) {
                                    boolean show= false;
                                    //logout session code
                                    ClientSideTimers.renewSessionTimer();
                                }
                            }
                        }
                    };
                    Event.addNativePreviewHandler(nativeHandler);
    

    if your screen stable for 2 minute than it will set expire session variable value false through timer and if value is false then do logout.

    SESSION_EXPIRED is a constant variable for session expired check not more that that SessionFactory is my custom factory code. U just ignore that used varibles which my project pattern. u have to just set one constant only not more than that. Let me know if still any query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.