Refresh Image Automatic from specific Folder

This article describe how to change image automatic after every 3 minute from specific folder.

If you click on start button then image refresh start and after every 3 min image change.


image.jsp
<%@ page language="java" import="java.util.*"%>
<%
List list = new ArrayList();
for (int i=0; i<8; i++ ) {
list.add("./images/000"+(i+1)+".jpg");
}
%>
<html>
<head>
<script language="JavaScript">
var i=0;
var ar = new Array();
<% for (int i=0; i<8; i++ ) { %>
ar['<%=i%>'] = '<%=(String) list.get(i)%>';
<% } %>

function MyTime() {
var img1 = document.getElementById("img1");
img1.src = ar[i];
i++;
if (i==6) i = 0;
setTimeout("MyTime()",3000);
}
</script>
</head>
<body>
<img src="./images/0001.jpg" height="200" width="200" id="img1" name="img1"/><br />
</br><br />
</br>
<form name="form1">
<input type="button" id = "btn1" name="btn1" value = "Start" onclick="MyTime()">

</form>
</body>
</html>