#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    181
    Rep Power
    14

    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?
  2. #2
  3. SwollenMember
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    the master control
    Posts
    264
    Rep Power
    15
    i am a bit confused on what you are trying to do...do you want the image to be a link?

    also...

    public class BannerBean
    is this working for you...

    public Bannerbean()

IMN logo majestic logo threadwatch logo seochat tools logo