How can I get a the host name (with port) that a servlet is at

后端 未结 5 1481
滥情空心
滥情空心 2020-12-08 19:06

I thought ServletContext might provide a method. Does the getAttribute() method of ServletContext provide any help i.e. is there an attribute name (maybe \"host\", \"port\")

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 19:14

    I have found in my old project the string:

    request.getHeader("host").contains("xxx")

    maybe it is the solution?

提交回复
热议问题