provided by: 
Originally published at Internet.comOne of the main advantages of JavaServer Pages is the ability to generate dynamic content. JSPs generate dynamic HTML pages by using Java control structures like for loops and if statements. As a result, forms can be generated dynamically following some specified logical layout.
Consider the simple task of generating a string repeatedly. This can easily be done by putting the string inside a for loop. The listing below provides a simple example of a JSP that generates a dynamic response to the user. The example consists of generating several progressively smaller HTML headers. Each header is lighter in color than the preceding one.
Listing: dynamicTitles.jsp
1:
Dynamic Titles 2:
3:
4: <% String[] colorArray = { "00", "11", "22", "33",
5: "44", "55", "66", "77",
6: "88", "99", "AA", "BB",
7: "CC", "DD", "EE", "FF"};
8: for(int j=1; j<5; j++){
9: String fgColor = colorArray[j*3]+colorArray[j*3]+colorArray[j*3];%>
10: 11: 12: JSPs are great !!!
13:
14: 15: <% } %>
16: 17:
Line 4 declares a colorArray containing a hexadecimal color string. Color in HTML is defined as the combination of the colors red, green and blue. Each of these has hexadecimal values from 00 to FF (0 to 255 in decimal), and the three are combined by concatenating their values. So purple would be FF00FF, black would be 000000, white FFFFFF, and so on...
Read article at Internet.com site