简体   繁体   中英

Is it possible to make a certain piece of code non functional?

I have set a response refresh header on my Jsp page. Like :

<% response.setIntHeader("Refresh",1) ; %>

It makes the jsp refresh at an interval of 1 second. But I want, that after a certain time is elapsed, the refreshing of the page after 1 second should stop. On a whole refreshing should stop. Is that possible ? I mean making a certain piece of code non functional.

The only way to make a piece of code or a code block non functional and functional is to wrap them in a conditional statement.

In your particular scenario keep a counter to see how many times the page is refreshed, or how much time has passed since the initial refresh (depending on how you want it) and wrap the refresh logic inside a conditional statement to check that the limit is not exceeded.

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