Session management in toolkit 5 beta

How to handle sessions in toolkit 5?

I wrote a program using tookit 4.2 and i used sessions as show in the code snipset below.

but now am changing to toolkit 5, now the following liblaries are not in tookit 5

import com.itmill.toolkit.service.ApplicationContext;
import com.itmill.toolkit.terminal.web.WebApplicationContext;

i need help how to do this in toolkit 5

package mainClass;

import javax.servlet.http.HttpSession;

import userInterface.FrontPageLayout;
import userInterface.HeaderLayout;

import com.itmill.toolkit.service.ApplicationContext;
import com.itmill.toolkit.terminal.web.WebApplicationContext;
import com.itmill.toolkit.ui.CustomLayout;
import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Component.Event;
import com.itmill.toolkit.ui.Component.Listener;

import controlClasses.LoginStatus;

 * This is the home page of all the UIs
public class HomepageDemo extends com.itmill.toolkit.Application implements Listener 
	public Window mainWindow = new Window("Net Sales Forum (Web 2.0 Project)");
	public CustomLayout mainLayout = new CustomLayout("MasterPageLayout");
	public ApplicationContext ctx;
	public WebApplicationContext webCtx;	
	public HttpSession session;
	public String username = "Anonymous";
	public int homeClickCount =0; // used to monitor how many clicks from home button..while the session is not valid
	public LoginStatus lstatus = new LoginStatus(0);
	 * Initialize Application. Demo components are added to main window.
	public void init() 
		ctx = getContext();
		webCtx = (WebApplicationContext) ctx;
		session = webCtx.getHttpSession();
		session.setAttribute("UserName", "Anonymous");
		new HeaderLayout(mainLayout, mainWindow, false);
		new FrontPageLayout(mainLayout, mainWindow);
	public void componentEvent(Event event) 


I ran in to this very same problem the other day when I was doing a pilot test moving an old millstone application to IT Mill Toolkit 5.

The WebApplicationContext class has moved to a different package and can be imported like this:

import com.itmill.toolkit.terminal.gwt.server.WebApplicationContext;

So, changing your WebApplicationContext import to the one above should work for your code.


hello Jonatan Kronqvist, thanks a lot for your valuable help.

nice work.