<% String[] ads = new String[] { "valueclick.jsp", "aaddzz.html", "leadcrunch.html" }; int[] probs = new int[] { 100, 0, 0 }; int tot = 0; for (int x =0; x < probs.length; x++) tot += probs[x]; double f = Math.random(); double t = 0; String forward = ads[0]; for (int x = 0; x < ads.length; x++) { t += ((double)probs[x]/tot); if (t > f) { forward = ads[x]; break; } } %>