简体   繁体   中英

How to call a method every X seconds using JSTL?

I have jsp page that displays the entries of a database. I also have a method that scans this database and which deletes the entries that have "expired". This is based on manipulating dates. I want this method to be called every X seconds in the jsp page using JSTL, so that the entries that have expired are no longer displayed. How would I accomplish this?

Once your JSP is loaded on browser, you can not invoke java code. So there is no point of having any logic to call method every x seconds through jsp.

However, You can -

  1. refresh your jsp every x seconds

  2. make an ajax call to fetch latest data from DB and display it using javascript/jquery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM