blob: 2ccfcbcd31df7aa268cae0ddf102fe3549c65c70 [file] [log] [blame]
刘洪青6266f992017-05-15 21:21:03 +08001<html><body><pre>
2&lt;%--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17--%>
18&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
19&lt;%@page contentType="text/html; charset=UTF-8" %>
20&lt;html>
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>