
July 13th, 2002, 11:08 PM
|
|
Contributing User
|
|
Join Date: Aug 2001
Posts: 181
Time spent in forums: 2 h 7 m 31 sec
Reputation Power: 7
|
|
|
rotating banner code
I have code from jsp book that use bean. but this code can rotate only image but not has link when click image
Code:
import java.util.Random;
public class BannerBean
{
private int index,count;
static private String [] banner_url =
{
"image1.gif",
"image2.gif",
"image3.gif"
}
public Bannerbean()
{
count = banner_url.length;
Random r = new Random();
index = r.nextInt(count);
}
public String getBannerurl()
{
return banner_url[nextIndex()];
}
private int nextIndex()
{
if(++index==count) index=0;
return index;
}
}
when use this code in jsp
<img src='<jsp:getProperty name="banner" property="bannerurl"/>'>
I want to edit code that can click each image and go to link. I know only define 2 dimention array
Code:
static private String [][] banner_url =
{
{"image1.gif","http://url1.com"},
{"image2.gif","http://url2.com"},
{"image3.gif","http://url3.com"}
}
but I don't know how to continue. Anyone help please?
|