The primary method for generating dynamic content on a JSP page is through the use of JSP expressions. A JSP expression is essentially a Java expression that is automatically converted to a String and written to the output stream. Here are some examples of JSP expressions:
The value of Pi is:
A random number between 1 and 100 is:
The value of the "p" request paramter is:
Today is:
Dynamic content can also be generated from a scriptlet by using out to write to the output stream. Here are some examples:
if (Math.random() > .5) {
out.println("You win!");
} else {
out.println("Sorry, you lose. Try again.");
}
%>