<%@page contentType="text/html; charset=UTF-8" %> JSP Chat
Message:

<% String serverName = request.getServerName(); if ("localhost".equals(serverName)) { serverName = "127.0.0.1"; } else if ("127.0.0.1".equals(serverName)) { serverName = "localhost"; } String chatUrl = request.getScheme() + "://" + serverName + ":" + request.getServerPort() + request.getContextPath() + request.getServletPath(); // strip "post.jsp" from the address chatUrl = chatUrl.substring(0, chatUrl.lastIndexOf("/") + 1); %> Click to open a new chat window Note: To avoid hitting the limit on the count of simultaneous connections to the same host, imposed by the HTTP specification, the second chat window should be opened using a different URL, e.g. with an IP address instead of the host name.