在jsp页面上动态更新日期

在jsp页面上动态更新日期,jsp,tags,Jsp,Tags,我使用自定义标记获取当前日期 public int doStartTag() { log.info("try to init JSpWriter"); JspWriter out = pageContext.getOut(); log.info("try to get date"); try { SimpleDateFormat printFormat = new SimpleDateFormat("HH:mm:ss"); ou

我使用自定义标记获取当前日期

public int doStartTag() {

    log.info("try to init JSpWriter");
    JspWriter out = pageContext.getOut();

    log.info("try to get date");
    try {
        SimpleDateFormat printFormat = new SimpleDateFormat("HH:mm:ss");
        out.println(printFormat.format(new Date()));
    } catch (IOException e) {
        log.error(null, e);
    }

    return SKIP_BODY;

}
然后像这样在页面上使用它


但是如何动态地更新它呢?因为它是静态的,在我更新页面时会发生变化。

使用JavaScript。谷歌搜索“JavaScript中的数字时钟”,但我想使用标签。标签用于在服务器上生成HTML。一旦HTML进入浏览器,如果你想每秒钟更新一次,最好使用JavaScript。螺丝刀不是挖洞的合适工具。JSP标记不是不断更改网页上文本的正确工具。我需要使用自定义标记-这是一项任务-但除了日期和语言之外,我没有任何想法。谷歌搜索“JavaScript中的数字时钟”