<

JSP Auto Refresh

setIntHeader() method is used to refresh web page in JSP.It refresh web page automatically given interval of time.


Jsp Auto Refresh syntax


public void setIntHeader(String header, int headerValue)


JSP Auto Refresh Example


<%@ page import = "java.io.*,java.util.*" %> 

<html> 
   <head> 
      <title>JSP Auto Refresh Example</title> 
   </head> 
   
   <body> 
      <center> 
         <h2>JsP Auto Refresh Example</h2> 
         <% 
            // Set refresh, autoload time as 5 seconds 
            response.setIntHeader("Refresh", 5); 
            
            // Get current time 
            Calendar calendar = new GregorianCalendar(); 
            String am_pm; 
             
            int hour = calendar.get(Calendar.HOUR); 
            int minute = calendar.get(Calendar.MINUTE); 
            int second = calendar.get(Calendar.SECOND);
             
            if(calendar.get(Calendar.AM_PM) == 0) 
               am_pm = "AM"; 
            else 
               am_pm = "PM"; 
            String CT = hour+":"+ minute +":"+ second +" "+ am_pm; 
            out.println("Crrent Time: " + CT + "\n"); 
         %> 
      </center> 
    
   </body> 
</html> 















© copyright 2017-2022 Completedone pvt ltd.