Aliaksei Bulhak
Aliaksei Bulhak

Reputation: 6208

Update dynamic JSP content

I have Web application. I use Struts2. And I have little JSP:

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
  <body>
    <s:form action="updateForm">
      <s:text name="news.page.main.label"/>
      <s:iterator status="stat" value="news">
        <table>
          <tr>
            <td><s:property value="title"/></td>
            <td><s:property value="body"/></td>
          </tr>
        </table>
      </s:iterator>
    </s:form>
  </body>
</html>

This page has table with news. For example I have 2 users that open this page and at some time one of them add new row. and I want page of second user update this page for example every 5 minutes.

How can I do this with the help struts2 or JS?

Please give some code for example.

Upvotes: 2

Views: 1122

Answers (2)

Reimeus
Reimeus

Reputation: 159754

One solution is to use a Javascript setTimeout to make an AJAX call to your Struts action.

I've given the jQuery link here as it makes this type of work a lot easier.

Upvotes: 4

Chris
Chris

Reputation: 5654

If you are free to use any ajax frameworks, I would say try Direct Web Remoting and use reverse AJAX.

Upvotes: 3

Related Questions