0

In my application i need to get any response to the jsp page automatically without any user action occur. How can i get that type of response like print some text to the jsp or invoke any function of the jquery from the server. Im using apache-tomcat7.0.42 and struts2 spring3 framework.

Hariprasath
  • 828
  • 4
  • 15
  • 41
  • At what basis you want it to get that response? Are you looking for ajax kind of solution? need some more demonstration... – Jai Sep 17 '13 at 12:24
  • 1
    i need ajax kind of response for my page, that response should come once for every 10 mins like that. – Hariprasath Sep 17 '13 at 12:26
  • okay! then what have you tried with ajax kind of stuff, plz post some code to lookup. such little info is not enough to answer it. – Jai Sep 17 '13 at 12:29
  • i need to tell the user as within some minutes ur session will timed out so i tried script timeout and timer function, that may arise some error. so i need some trigger from server side to invoke my script. – Hariprasath Sep 17 '13 at 12:39

2 Answers2

1

Seems you need meta tag refresh

<meta http-equiv="refresh" content="10; url=urlToFetchData">
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

You can use like below or you can use meta tag refresh

<%@ page import="java.io.*,java.util.*" %>
<html>
<head>
<title>Auto Refresh Header Example</title>
</head>
<body>
<center>
<h2>Auto Refresh Header 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>
abcd
  • 3,164
  • 2
  • 18
  • 13