A declaration section contains java variable and method declarations. These declarations become methods/variables of the generated page class and are available from within the rest of the page.

A page can have as many declaration sections as desired.

The page framework creates only 1 instance of a page so there is no performance difference between a static and instance variable. Since more than 1 thread can be rendering a page, any declared method should be synchronized as/when needed.


.. java instance and static methods/variables ..


To prevent the tag from being recognized, this tag can be escaped by prefixing the start tag with a backslash: \[!


A molly page containing instance and static fields.

The results section (below, right) shows the browser the first time the page is accessed and then below, the second time the page is accessed.

[! static final String GREETING = "Hello World"; int num = 0; int getNumber() { return num++; } !] <html> <body> [=GREETING]. The next number is: [=getNumber()] </body> </html> Hello World. The next number is: 0 Hello World. The next number is: 1