| 刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 1 | <html><body><pre>
 | 
 | 2 | <%--
 | 
 | 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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 | 
 | 19 | <%@page contentType="text/html; charset=UTF-8" %>
 | 
 | 20 | <html>
 | 
 | 21 | <head>
 | 
 | 22 |    <title>JSP Chat</title>
 | 
 | 23 | </head>
 | 
 | 24 | 
 | 
 | 25 | <body bgcolor="#FFFFFF">
 | 
 | 26 | 
 | 
 | 27 | <form method="POST" action='chat' name="postForm">
 | 
 | 28 | <input type="hidden" name="action" value="post">
 | 
 | 29 | Message: <input type="text" name="message">
 | 
 | 30 | <input type="submit">
 | 
 | 31 | </form>
 | 
 | 32 | 
 | 
 | 33 | <br>
 | 
 | 34 | <%
 | 
 | 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 | <a target="_blank" href="<%=chatUrl %>">Click to open a new chat window</a>
 | 
 | 50 | <em>Note</em>: To avoid hitting the limit on the count of simultaneous
 | 
 | 51 | connections to the same host, imposed by the
 | 
 | 52 | <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4">HTTP specification</a>,
 | 
 | 53 | the second chat window should be opened using a different URL, e.g. with
 | 
 | 54 | an IP address instead of the host name.
 | 
 | 55 | </body>
 | 
 | 56 | </html>
 | 
 | 57 | </pre></body></html>
 |