Using for loop or switch case:)

Hey guys do you have any link that like

for example: The user enter number 1 in the textfield and when onclick right, it will show the number 1 image on another jsp page. And if the user enter number 2, it will show the number 2 image. I placed the images in database.

Is it something to do with like for loop that is embedded inside the jsp or is it using swich case?