<%! private java.util.Random mRandomGenerator = new java.util.Random(); private int getRandomNumber(int range) { return mRandomGenerator.nextInt(range); } %> <html> <head><title>Random numbers demo</title></head> <body> <% for (int i=1; i<=5; i++) { %> Random number #<%= i %> is <%= ""+getRandomNumber(1000) %>. <br> <% } %> </body> </html>Back to Internet Programming with Java books's web site