简体   繁体   中英

How to include new page on jsp page in every 10 sec?

Hi i am trying to include a new jsp page on my jsp page in every 10 sec how can i achieve this

i am able to include page but not including according to time

Here is my code

<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html>
<head>
<title>Untitled Document</title>
  section
 {height:70%; background-color:blue; display:block; overflow:auto;}

section .push {height:500px;}
</style>
</head>
 <body>
    <form action="F1.jsp" method="post"> 
     <%@ include file="F2.jsp" %> 
      <footer>footer</footer>
    </form>
</body>
</html>

How can i achieve this

Thanks in advance

如果要包含更多内容或刷新页面的一部分,则需要使用浏览器端JavaScript从服务器提取新内容。

Once you display something using JSP, that is final. It cannot change unless you provide the mechanisms to change. You can set a refresh rate of your JSP to auto refresh and display each time a new content.

Or you can use AJAX.

How to do it using ajax (I prefer the JQuery version) can be found here at the answer with 5 upvotes

You can set interval in Javascript.

syntax:

setInterval(function(){
    // code //
},10000);

In the code you can use Ajax calls which pool the content of JSP from the server.

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