Java - JSTL, random number between values

Add the bellow tag to your jsp page:

<jsp:useBean id="random" class="java.util.Random" scope="application"/>

, and the followin tag to generate your random number:

${random.nextInt(N)}

Particular case:
Generate a random number, between 1 and 4, in order to display a different background at each page refresh:

<img src="../img/background_${random.nextInt(3)+1}.jpg">

Comments

Popular posts from this blog

Oracle - duplicate fields in RECORD,TABLE or argument list are not permitted

Oracle - ORA-29282: invalid file ID, ORA-06512: at "SYS.UTL_FILE"