Imagens atualizadas

Pessoal,

Tenho um for que carrega uma lista de imagens que está em uma determinada pasta:

<% for(int i = 1; i <= slidesCount; i++) { %>    
                <div style="height: 3000px; width: 100%; display: none;" id="slide<%= i %>_div">
                    <a name="#slide<%= i %>"></a>
                    <% if(new java.io.File(p.getPath(), "slides" + java.io.File.separator + "slide" + i + ".jpg").exists()) { %>
                        <img src="<%= presentationURL %>slides/slide<%= i %>.jpg" id="slide<%= i %>" 
                             onload="javascript:adjustImgSize('slide<%= i %>');"/>
                    <% } else { %>
                        <img src="<%= presentationURL %>slides/slide<%= i %>.png" id="slide<%= i %>" 
                             onload="javascript:adjustImgSize('slide<%= i %>');"/>          
                    <% } %>    
                </div>
            <% } %>

Mas agora esta quantidade de imagens poderá modificar.

Como faço para fazer com que a página contenha essas imagens q estão sendo modificadas?

Vinicius.

O slidesCount é formado assim:

<% 
    int slidesCount = 0;
    ResourceBundle msgs = ResourceBundle.getBundle("br.com.cpqd.www.dmd.Messages", request.getLocale());
    ResourceBundle bundle = ResourceBundle.getBundle("br.com.cpqd.www.dmd.dmdweb_config");
    Presentation p = null;
    String presentationURL = null;
    long id = Long.parseLong(request.getParameter("presentationID"));
    Long hid = null;
    try {
        DAO dao = DAOFactory.getDAOInstance(DAOFactory.PRESENTATION_DAO, request.getLocale());
        p = (Presentation) dao.getObject(id);
        try {
            HistoryEntry h = new HistoryEntry();
            h.setPresentationID(new Long(id));
            h.setUserID(((User) ((HttpServletRequest) request).getSession().getAttribute("user")).getId());
            h.setStartTime(new Timestamp(System.currentTimeMillis()));  
            DAO histDao = DAOFactory.getDAOInstance(DAOFactory.HISTORY_DAO);
            histDao.createObject(h);
            hid = h.getId();
        } catch(Exception e) {
            System.out.println("Error while processing history information: " + e);
            e.printStackTrace();
        }
        if(p.getPresentationType().equals(Presentation.LIVE_PRESENTATION)) {
            slidesCount = new File(p.getPath(), "slides").listFiles(new FileFilter() { 
                public boolean accept(File file) {
                    return file.getName().toLowerCase().endsWith(".jpg") ||
                    file.getName().toLowerCase().endsWith(".png");
                }//accept
            }).length;
            String baseUrl = bundle.getString("presentation.base.url");
            String baseDir = bundle.getString("presentation.directory");
            String presentationDir = p.getPath().getAbsolutePath().substring(baseDir.length());
            presentationDir.replace('\\', '/'); //in case this is running on windows
            if(!presentationDir.endsWith("/")) {
                presentationDir = presentationDir + "/";
            }
            if(!(presentationDir.startsWith("/") || (baseUrl.endsWith("/")))) {
                presentationURL = baseUrl + "/" + presentationDir;
            } else {
                presentationURL = baseUrl + presentationDir;
            }
            br.com.cpqd.www.dmd.comm.PresentationManager.setLastAccessTime(id, new Long(System.currentTimeMillis()));
        }
    } catch(Exception e) { 
        System.out.println("Error while processing presentation information: " + e);
        e.printStackTrace();
    }
%>

e o adjustImgSize assim:

function adjustImgSize(imgId) {
                    var image = document.getElementById(imgId);
                    var winW = document.body.clientWidth;
                    document.getElementById(imgId + "_div").style.display = 'block';
                    if(image.width != winW) {
                        image.height = image.height * (winW / image.width);
                        image.width = winW;
                    }
                }