This section illustrates you how client gets auto refresh.
We are providing you an example which explains you clearly. In the example, We have created the session by request.getSession() method. The method response.addHeader("Refresh", "15") refreshes the servlet after every 15 seconds till the servlet gets destroy.
Here is the code of ClientAutoServlet.java
import javax.servlet.ServletException;
|
In web.xml, do the servlet-mapping
| <servlet> <servlet-name>ClientAutoServlet</servlet-name> <servlet-class>ClientAutoServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ClientAutoServlet</servlet-name> <url-pattern>/ClientAutoServlet</url-pattern> </servlet-mapping> |
Output will be displayed as:

After 15 seconds, page will get refresh. Output will be:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Client Auto Refresh in Servlets View All Comments
Post your Comment