permaculture playing cards*
The moose likes Beginning Java and the fly likes an odd request, lookup within jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "an odd request, lookup within jsp" Watch "an odd request, lookup within jsp" New topic
Author

an odd request, lookup within jsp

Stan F Smith
Greenhorn

Joined: Jun 28, 2011
Posts: 20
Hello,
I have a req that everthing be within a single jsp file. The page takes in as a param a number and I need to map it to an image. I know i could do it with a huge if statement but there has to be a better way.

for instance

String path = "";
if(num == 1)
path = "people.jpg"
else if(num == 2)
path = "sun.jpg"
else if(num == 3)
path = "moon.jpg"
....

and so on for about 50 images
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You could have a string array, or a map, for example. But your question is about Java, isn't it? The fact that it's going to be dumped in a JSP page as if it were still 2003 is not particularly relevant. So let's move this to one of our forums where questions about Java are answered.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: an odd request, lookup within jsp
 
Similar Threads
Finding the largest Prime Factor
charAt with longs?
prime numbers -please help
Windows (server) 2000 and JSP page not displaying correctly
Problem in window.close; page get requested again