How to create and work with HttpSession

I’ am new in Vaadin. I came from struts. I notice the “Book of Vaadin” and build so my frist Vaadin-Application.

But I never find how to create, use and work with a HttpSession on a vaadin appilication.

I looking for:
At the start of my application I will create a HttpSession and create so a sessionDataHolder too.
I want to set length of the session.
The SessionDataHolder should be valid over my applicatiion.
The SessionDataHolder should be store information from my application.
So I will access to the session (request, respose) and the SessionDataHolder in each element (Window, Component) in my application.
The HttpSession request should include my Form parameter so I’am able to ask the request for the parameter and change so my domain objects.

And when I stop my application the session and the my SessionDataHolder is invalid.

It is possible with Vaadin?
Or must I think to build application on an other way, when I will use vaadin?

How can I find information about my questions? (Online, Books, here)

Thanks in advance for your help


Vaadin already takes care of all of this for you, though normally you’d set the session length in your deployment descriptor. It creates a session and stores an instance of your Application class in it. You don’t have to do any of that manual work. Unlike Struts, where you create an action class for handling your form and an html representation of the form that will be submitted, in Vaadin you just have a Java class to represent your form and call methods on it to get the data.

For instance, you can create a text field and button (a little simpler than the Vaadin Form object for this example). Add a listener to the button, and when it’s clicked you can get the text field contents with


You don’t need to hassle with storing that info in the HttpSession and then retrieve it. Any fields you have in your Application class or its fields will be stored in the session for you. (For example,
here’s a simple case I recently posted
that holds the state of a counter. Note that I never needed to access the session to do this.)

If you want to get the HttpSession during a request for some other reason, you can do that easily by implementing the HttpServletRequestListener interface. I hope that helps.


Thanks Bobby,

yes that helps a little bit.