Session is mixed up?

I have another problem I’m stuck at since 2 days.

I start my server (Tomcat 7) and open IE and firefox, or use built-in browser of Eclipse and Firefox, and it works good, but as soon as I call a method to add a new String item to a vector, if another session is open, the method is also called from that session.

I’ve made a totally new app without anything fancy used, and still got the problem. If I call the “addThis(stg.getValue())” when I push a button from Firefox, then it is also called from any other session if I’m at the same page. If the textfield is empty in the other browser, then it is called with an empty string. If I use a new pop-up window to enter the data, then the window also pops up in the other browser!! That’s really strange, and I can’t figure out what causes it.

You have a singleton (static class), or you are sharing variables in a servlet.

I don’t have any singleton class in the new project (I have in the original but I figured that’s not the problem there).

I only use those variables that I define in my class. How can I even use a shared variable in the servlet?

Heres my source code for the simple test app I did (it’s a mess, sorry, I used it for testing):

public class TeeesztApplication extends Application  {
	public void init() {
		Window mainWindow = new Window("Teeeszt Application");
		Label label = new Label("Hello Vaadin user");
		new TestWindow(mainWindow);

public class TestWindow extends VerticalLayout implements ClickListener {

    public class ChatRefreshListener implements RefreshListener {
			public void refresh(final Refresher source) {
    private Window subWindow, mainWindow;
    private SomeClass some = new SomeClass();
    VerticalLayout l2 = new VerticalLayout();

    private TextField tfNew = new TextField("name: ");
    private static final Button btCreateRoom = new Button("New");
    private static final Button btRefresh = new Button("Referesh");
    Table table = new Table("rooms");

    public TestWindow(Window main) {
    	mainWindow = main;
subWindow = new Window("Információ");
        final Refresher refresher = new Refresher();
		refresher.setRefreshInterval(2000);		//no data is sent to the user if nothing is written
		refresher.addListener(new ChatRefreshListener());

        // Allow selecting items from the table.
        // Send changes in selection immediately to server.
        // Shows feedback from selection.
        final Label current = new Label("Selected: -");
        // Handle selection change.
        table.addListener(new Property.ValueChangeListener() {

		public void valueChange(ValueChangeEvent event) {
        current.setValue("Selected: " + table.getValue());


		public void setRoomsTable() {
			table.addContainerProperty("Szoba neve", String.class, null);
			for (int i = 0; i < some.getRooms().size(); i++){
				table.addItem(new Object[] {some.getRooms().get(i)}, new Integer(i+1));
		public void buttonClick(ClickEvent event) {
			if (event.getButton() == btCreateRoom){
				String s = (String)tfNew.getValue();
			} else if(event.getButton() == btRefresh){

public class SomeClass {
	private static Vector<String> vektor = new Vector<String>();

	public SomeClass(){
	public void setRooms(String s){
	public Vector<String> getRooms(){
		return vektor;

Maybe the static Vector? That would be a surprise.

The buttons are static.

Yeah, I feel stupid now :slight_smile:
Thank you for pointing my mistake out!
But in my original project, I remember correcting this mistake, better check it out. I even remember realizing back then I forgot to delete the static keyword, because I was lazy and just copy pasted a code fragment.
Tried it on my posted test project, that was the problem there…

Thank you all again! I’m all over my head lately.

Edit: Yes, in my original project, there is no static variable. But still doesn’t work good, as i have a hashmap in the singleton class, every time a user logs in, his name gets in the hashmap as the key, with a null at first (will be the roomname he joins later) but when I join in vaadin built in browser - the one user shows fine. Then I join in firefox - 2 user show fine. Then I join in Chrome (even tried with IE) and the 3 users show fine on the last used browser, but on the other 2, it shows the second users name, so 2 users are logged in at the same time, and the third is not even logged in (according to the first two browser I used). And how can that even be?!? A hashmap cannot have 2 identical key, and I call the same method rendering the table that shows the logged in users always, still show different values…
For example user1, user2 and user3 logs in. When user3 logs in, he sees:
Logged in users: user1, user2, user3
But user1 and user2 sees:
Logged in users: user1, user2, user2

And I triple made sure no static variables this time.

Well, maybe I’ll try something else then hashmap.