Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Global Vars

Michael Froherz
10 years ago Mar 19, 2012 8:02am
Kim Leppänen
10 years ago Mar 19, 2012 8:48am

If your global variables are application instance specific, then take a look at the ThreadLocal pattern.

If your global variables shared across all applications, then statics are fine as long as your application is running inside one JVM.

Michael Froherz
10 years ago Mar 19, 2012 9:38am
Kim Leppänen
10 years ago Mar 19, 2012 10:13am
Michael Froherz
10 years ago Mar 19, 2012 11:13am

Thanks for the help!
I have the use of

"public class app extends Application implements HttpServletRequestListener {
private static ThreadLocal local = new thread <app> <app> ThreadLocal ();"

derived and write a class of the variable with getter and setter.
I call it "userData".

With the assignment "app.getInstance().setUserData (name, firstname, User_ID, ...). can read and assign the values ​​corresponding to the current session.

This seems to work ...:grin:

Last updated on Mar, 19th 2012
Bobby Bissett
10 years ago Apr 02, 2012 8:34pm