blob: 90fa32373e340587d2ebb01b7a83eacf404578eb [file] [log] [blame]
Hongqing Liufd5ee812014-05-10 16:32:51 +08001<html><body><pre>
2&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3&lt;%@page contentType="text/html; charset=UTF-8" %>
4&lt;html>
5&lt;!--
6 Licensed to the Apache Software Foundation (ASF) under one or more
7 contributor license agreements. See the NOTICE file distributed with
8 this work for additional information regarding copyright ownership.
9 The ASF licenses this file to You under the Apache License, Version 2.0
10 (the "License"); you may not use this file except in compliance with
11 the License. You may obtain a copy of the License at
12
13 http://www.apache.org/licenses/LICENSE-2.0
14
15 Unless required by applicable law or agreed to in writing, software
16 distributed under the License is distributed on an "AS IS" BASIS,
17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 See the License for the specific language governing permissions and
19 limitations under the License.
20-->
21&lt;head>
22 &lt;title>JSP Chat&lt;/title>
23&lt;/head>
24
25&lt;body bgcolor="#FFFFFF">
26
27&lt;form method="POST" action='chat' name="postForm">
28&lt;input type="hidden" name="action" value="post">
29Message: &lt;input type="text" name="message">
30&lt;input type="submit">
31&lt;/form>
32
33&lt;br>
34&lt;%
35 String serverName = request.getServerName();
36 if ("localhost".equals(serverName)) {
37 serverName = "127.0.0.1";
38 } else if ("127.0.0.1".equals(serverName)) {
39 serverName = "localhost";
40 }
41
42 String chatUrl = request.getScheme() + "://" + serverName + ":"
43 + request.getServerPort() + request.getContextPath()
44 + request.getServletPath();
45
46 // strip "post.jsp" from the address
47 chatUrl = chatUrl.substring(0, chatUrl.lastIndexOf("/") + 1);
48%>
49&lt;a target="_blank" href="&lt;%=chatUrl %>">Click to open a new chat window&lt;/a>
50&lt;em>Note&lt;/em>: To avoid hitting the limit on the count of simultaneous
51connections to the same host, imposed by the
52&lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4">HTTP specification&lt;/a>,
53the second chat window should be opened using a different URL, e.g. with
54an IP address instead of the host name.
55&lt;/body>
56&lt;/html>
57</pre></body></html>