This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
oops...sorry moderators, actually when I tried posting it, it gave me some errors so I used my browser back button and resubmitted it again and later I found it to be duplicated. You can delete this post as I'll use the other one!
Note that the example is using two kind of scriptlets: declarations (<%! %> and scripting expressions (<% %>. The Date code is inside an scripting expression, so it will be put inside the _jspService method during translation. The other two blocks are declarations, which means they will be put outside the _jspService method. What is more, both blocks are declaring a jspInit method, which will be run only once during servlet initilization (that's why the second time you'll see no output in the log).