Hi I have a query regarding image reload in a jsp page
My code is :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Script for auto refresh of graphs with 5 seconds interval -->
<script type="text/javascript">
var load, generation, store, EP,transaction,Battery;
window.onload = function() {
transaction = document.getElementById("Transaction");
setInterval(function() {
transaction.src = transaction.src.replace(/\?.*/, function() {
return '?' + new Date()
})
}, 1000)
}
</script>
<%!
public String transactionFunc(){
System.out.println("---------transactionFunc------------");
String name=PSMApp.getInstance().notif.getTransaction();
String src = "../Stylesheet/images/EnergyDeficit256.png";
if(name!=null && name.equals("BUY")){
src = "../Stylesheet/images/EnergyDeficit256.png";
}
else if(name!=null && name.equals("SELL")){
src = "../Stylesheet/images/EnergySurplus256.png";
}
return src;
}
%>
<div class="col-md-4">
<img src=<%=transactionFunc() %>id="Transaction">
</div>
</body>
</html>
when I am trying to reload the image using Javascript above, it is not calling the transactionFunc() which is a jsp function (This function accesses a java class and gets the updated value of source of <img>
tag.
How to resolve this issue so that transactionFunction() gets called every time the image is reloaded?