Simple way to output the value of a java variable.


Expression sections can appear anywhere in text or hash sections.
[= java_variable_or_expression]
Essentially, instead of saying out.println(whatever), one can say [= whatever]. (both are exactly equivalent).


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

If an expression contains a java array, such as: [= x[i]], the ending ] of the array is seen as the end of the expression itself. The solution is to say: [= x[i\]] instead.


A simple molly page containing a simple expression. <html> <body> [= 2+2 ] </body> </html> 4


Expressions can contain either valid java expressions or previously defined page variables. <html> <body> [[ int feel = 0; String greeting = "Hello World"; ]] [= greeting ].. [= ((feel == 0) ? "I feel good today" : "I need a change") ] </body> </html> Hello World..I feel good today


An expression is convenient when writing an attribute value. <html> <body> [[ String color = "#ccc"; ]] <table bgcolor='[=color]' cellspacing=2> <tr><td>Hello world</td></tr> </table> </body> </html>
Hello world