I am working on web project where I have to generate image and display it on JSP page when it gets load. Now the problem is that I am have to use same image name and hence browser is using cached image always and not the new one.
Display.jsp
<html>
<head>
<script type="text/javascript">
updateImage(){
var img1 = document.getElementById("text");
img1.src="sun.png?time=".new Date().getTime();
}
</script>
</head>
<body onload="updateImage()">
<form action="com.CheckName" method="get">
<input type="button" value="submit" name="submit" />
<img src="sun.png" id="text">
</form>
</body>
</html>
By clicking on button same jsp page gets loaded again. I am using above code but still I am getting cached(old) image only on next page load. Where I am going wrong.
Please help.
Thanks