【发布时间】:2013-02-26 23:03:08
【问题描述】:
我有一个 Java Servlet 容器。这个 servlet 容器可以服务于localhost:8080、192.168.1.2:8080、www.development.example 或www.production.example.com。如何让 Servlet 容器和/或任何正在运行的 servletsense 它正在服务哪个域名?
【问题讨论】:
-
您想知道“父”页面是什么吗? servlet 是如何包含进来的?
-
getLocalName on ServletRequest 应该给你你想要的。
-
@BevynQ - 这将返回运行应用程序的机器的主机名,它可能与虚拟主机名不同。 getServerName() 是更好的选择。