Scope Of the bounded variables

hope this is a right place to ask this.
1-how can I define the scope of the variables? for example how can I store a variable in user session or in the scope of application?

2-What is the boundary for server side and client side code?
since developer cannot see a separation between a client side code and a server side code I wonder where is the border for that?
In GWT framework as far as I know there is a client package that only those codes reside in this package or any package marked as client are being compiled to javascript, other codes are considered as server side.
for example in vaadin if I create a button and onClick of that button I create a file then this file is created on the server not on the client. In fact as a developer how can I see when I’m coding client side and when I’m coding server side?

Thanks so much in advance

Some short answers:

1: You can consider an instance of an Application class (subclass that is) as users session. That means that every variable bound to application has also the same life-cycle. So to create session scoped variable just create a field into a class.

2: We follow the GWT convention that everything under client.* package is run in the browser. Typically there is MyComponent class for server-side and a VMyComponent (under .client.ui. package) for the client-side code.

And for accessing the application instance, you should check out the
Threadlocal Pattern