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 7159009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:09:35+00:00 2026-05-28T13:09:35+00:00

i am working on a GWT web application and i was wondering if there

  • 0

i am working on a GWT web application and i was wondering if there is a way to keep some classes alive on the server.

The point is that i would like to create a static class that will run on the server and manage something for me.. lets say currently logged in users.

public class someclass{

private static someclass instance;
private List<user> users;
private someclass(){
users = new ArrayList<user>();
}
public someclass getInstance()
{
    if (instance == null)
        instance = new someclass(); 
    return instance;
}
public addUser(user u)
{
users.add(user);
}
}

assume that there is no sync needed its not impotent for the question.

lets say first user logs in, and is added to the users list.
when a second user logs in. will the user list be empty? or will it have the old user as well?

Thanks…

  • 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-05-28T13:09:36+00:00Added an answer on May 28, 2026 at 1:09 pm

    There are different ways to do this. However, a very simple way to tackle this scenario would be to use a startup servlet
    In web.xml define it as follows.

    <servlet>
     <servlet-name>TestServlet</servlet-name>
     <servlet-class>TestServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
    </servlet>
    

    Maintain the stat in static fields of that servlet.

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

Sidebar

Related Questions

Im trying to get some simple javascript working in gwt but keep failing. The
I am working a resonably sized java project that needs some sort of web
I am working on converting the functionality of some JSP pages to GWT. I
I'm working with a project where I use GWT. There's no problems with it,
I am working on a GWT application which uses GWT-RPC. I just made a
I'm developing a web UI using GWT. While working only with the widgets I
I'm working on an iPhone application that should work in offline and online modes.
I'm working on a GWT project, in which I have to fetch some JSON
we are developing an web application using GWT 2.4, Errai 1.3.2. It is running
I'm working with Vaadin, a GWT like framework for developing rich web applications. Now

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.