You can submit the form via AJAX and use Ajax with Spring MVC to poll new log entries and add them to the table on your page. Here's the quick code for calling AJAX to check for a new log entry using JQuery and Spring's MVC controller method to handle it.
JSP:
$.getJSON("logs.htm", { lastLogId: logId }, function(response) { $('#myTable tr:last').after('<tr><td>' + response + '</td></tr>'); });
Spring MVC controller (returns JSON):
@Controller public class LogController { @RequestMapping("logs.htm") public @ResponseBody String getLogs(@RequestAttribute("lastLogId") Integer lastLogId, HttpSession sess) { LogList logs = sess.getAttribute("logs");
There are several parts that I did not mention here (it would be necessary to write log entries to the session when log4j logs, etc.), but I hope that at least it is useful to see a way to do this using Spring MVC and AJAX.
source share