开发者

JBoss/Tomcat/Struts2 Server Boot Point in Time?

开发者 https://www.devze.com 2023-02-17 23:01 出处:网络
I\'m writing a web app in Struts2 that runs on a JBoss (or Tomcat). I\'d like to know when the server has started so I can use that point in time for caching purposes. In particular, I want to set th

I'm writing a web app in Struts2 that runs on a JBoss (or Tomcat).

I'd like to know when the server has started so I can use that point in time for caching purposes. In particular, I want to set the "Last-Modified" header to the time when the server last booted.

Any idea how to get this information within an action?开发者_JAVA技巧 I imagine that there must be some java code buried in e.g. Struts2 ready for this.

Thanks in advance!


A non-JBoss/Struts2 way to do this would be to create a Servlet configured to be initialized when the container starts up (via the load-on-startup tag in web.xml) and in that Servlet's init() methods save the current time (in Application Scope).

0

精彩评论

暂无评论...
验证码 换一张
取 消