webtier@glassfish.java.net

Re: [webtier] Glassfish, JSPs and Java classes. How static is static?

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Tue, 28 Jul 2009 09:36:42 -0700

On 7/27/09 4:18 AM, webtier_at_javadesktop.org wrote:

> It's not clear to me whether the methods in the tier 2 classes should be static or not. All they're doing is getting some data out of the database based on parameters given to them, chucking it in an object and returning it to the JSP, which then formats the output. Within the context of the application server, how static is a static variable? Is there one per request? Per thread? One for the entire server instance? If the tier 2 methods are static, will an executing request block all further requests until that method is complete?

It's the same as any VM - nothing special, since the static modifier is
a VM property.

But you're mixing up method and variable. The two are quite different,
naturally. You show a method, but then ask about variables. Which do
you mean?

Static methods won't be any problem for you. There's no concurrency
problem associated with using them. So the code you show should be fine.

Jim