I am displaying TIFF image through applet from my jsp page.
For multipage tiff image, i split the image and then calling applet for image.

For single page tiff image it is working fine. But in case of multipage tiff file, I am getting the same image in each applet.

My jsp file code is as below.

Java Code:
 if( files != null && files.length > 0)  
{  
   for (int x=0;x<files.length;x++)  
  {  
    if( (files[x].getName()).contains(sid))  
   {  
       path = files[x].getPath();  
     %>  
      <div id="img_<%=n++%>">  
     <tr>  
       <td>  
          <applet name="MyApplet_<%=x%>" code="MyApplet.class" archive="jai_codec.jar,jai_core.jar" width="500" height="500">  
             <param name="count" value="<%=x%>">  
             <param name="imgPath_<%=x%>" value="<%=path%>">  
             <param name="serverIP" value="<%=serverIP%>">  
             <param name="port" value="<%=port%>">  
             <param name="appname" value="<%=Constants.APP_NAME%>">  
          </applet>  
       </td>  
    </tr>  
     <div>  
    <%  
   }  
 }  
}

and my applet code is as below

Java Code:
public class MyApplet extends Applet {  
      
    private static final long serialVersionUID = 1L;  
    private static Image img;  
    MediaTracker tr;  
    String path = "";  
    String cntStr = "";  
    int cnt = 0;  
  
    public void init() {  
        tr = new MediaTracker(this);  
  
        cntStr = getParameter("count");  
        System.out.println("cntStr :: "+cntStr);  
        cnt = Integer.parseInt(cntStr);  
  
        String imgPath = getParameter("imgPath_"+cnt);  
        System.out.println("imgPath :: "+imgPath);  
  
        String serverIP = getParameter("serverIP");  
        System.out.println("serverIP :: "+serverIP);  
  
        String port = getParameter("port");  
        System.out.println("port :: "+port);  
  
        String appname = getParameter("appname");  
        System.out.println("appname :: "+appname);  
  
        int indx = imgPath.lastIndexOf(appname);  
        String relPath = imgPath.substring(indx);  
        System.out.println("indx :: "+indx);  
        System.out.println("relPath :: "+relPath);  
  
        try  
        {  
            URL url = new URL(image path);  
              
            RenderedImage im = JAI.create("url", url);  
            Image image = PlanarImage.wrapRenderedImage(im).getAsBufferedImage();  
  
            img = image.getScaledInstance(500, -1,  Image.SCALE_SMOOTH);  
            System.out.println("image: " + path + "\n" + image);  
            tr.addImage(img,cnt);  
        }  
        catch(Exception e)  
        {  
            e.printStackTrace();  
        }  
    }  
  
    public void update(Graphics g) {  
        paint(g);  
    }  
  
    public boolean imageUpdate(Image img, int flags, int x, int y, int width,int height)   
    {  
        System.out.print("Flag(s): ");  
        if ((flags & ImageObserver.WIDTH) != 0) {  
          System.out.print("WIDTH:(" + width + ") ");  
        }  
  
        if ((flags & ImageObserver.HEIGHT) != 0) {  
          System.out.print("HEIGHT:(" + height + ") ");  
        }  
  
        if ((flags & ImageObserver.PROPERTIES) != 0) {  
          System.out.print("PROPERTIES ");  
        }  
  
        if ((flags & ImageObserver.SOMEBITS) != 0) {  
          System.out.print("SOMEBITS(" + x + "," + y + ")->(");  
          System.out.print(width + "," + height + ") ");  
          repaint();  
        }  
  
        if ((flags & ImageObserver.FRAMEBITS) != 0) {  
          System.out.print("FRAMEBITS(" + x + "," + y + ")->(");  
          System.out.print(width + "," + height + ") ");  
          repaint();  
        }  
  
        if ((flags & ImageObserver.ALLBITS) != 0) {  
          System.out.print("ALLBITS(" + x + "," + y + ")->(");  
          System.out.println(width + "," + height + ") ");  
          repaint();  
          return false;  
        }  
  
        if ((flags & ImageObserver.ABORT) != 0) {  
          System.out.println("ABORT \n");  
          return false;  
        }  
  
        if ((flags & ImageObserver.ERROR) != 0) {  
          System.out.println("ERROR ");  
          return false;  
        }  
  
        System.out.println();  
        //repaint();  
        return true;  
    }     
  
    public void paint(Graphics g)  
    {  
        g.drawImage(img, 0, 0, this);  
    }  
}
so please anybody tell me how can i get this problem solved ?

Thanks in advance