Package demo

Source Code of demo.ClientServlet

package demo;

import javax.servlet.*;
import javax.servlet.http.*;
import com.trulytech.mantis.system.*;
import com.trulytech.mantis.result.*;
import com.trulytech.mantis.util.ClientInfo;
import java.sql.Statement;

/**
* <p>
* Title: ClientServlet
* </p>
* <p>
* Description: 获得浏览器信息
* </p>
* <p>
* Copyright: Copyright (c) 2002
* </p>
* <p>
* Company:
* </p>
*
* @author Wang Xian
* @version 1.2
*/

public class ClientServlet extends ActionServlet {

  // 重载身份校验函数
  protected int HasPermission(HttpServletRequest request,
      HttpServletResponse response, SQLParser Parser) throws Exception {
    return Permission.ALLOW;
  }

  /**
   * 执行doPost操作
   *
   * @return String
   * @param request
   *            请求
   * @param response
   *            response
   * @param Parser
   *            SQL解析器
   * @throws Exception
   */
  protected String PerformPost(HttpServletRequest request,
      HttpServletResponse response, SQLParser Parser) throws Exception

  {
    // 实例化ClientInfo类
    ClientInfo Client = new ClientInfo(request);
    StringBuffer Str = new StringBuffer();
    // 获得客户IP Address
    Str.append("Client IP Address:");
    Str.append(Client.getIPAddress());
    Str.append("<BR>");
    // 获得客户Host
    Str.append("Client Host:");
    Str.append(Client.getRemoteHost());
    Str.append("<BR>");
    // 获得客户Method
    Str.append("Method:");
    Str.append(Client.getMethod());
    Str.append("<BR>");
    // 获得客户URI
    Str.append("URI:");
    Str.append(Client.getURI());
    Str.append("<BR>");
    // 获得客户Protocol
    Str.append("Protocol:");
    Str.append(Client.getProtocol());
    Str.append("<BR>");
    // 获得浏览器类型
    Str.append("User-Agent:");
    Str.append(Client.getUserAgent());
    Str.append("<BR>");
    // 获得浏览器类型
    Str.append("Connection:");
    Str.append(Client.getConnection());
    Str.append("<BR>");
    // 获得浏览器可接受的MIME类型
    Str.append("Accept:");
    Str.append(Client.getAccept());
    Str.append("<BR>");
    // 获得浏览器可接受的字符集
    Str.append("Accept-Charset:");
    Str.append(Client.getAcceptCharset());
    Str.append("<BR>");
    // 获得浏览器能够进行解码的数据编码方式
    Str.append("Accept-Encoding:");
    Str.append(Client.getAcceptEncoding());
    Str.append("<BR>");
    // 获得浏览器所希望的语言种类
    Str.append("Accept-Language:");
    Str.append(Client.getAcceptLanguage());
    Str.append("<BR>");
    // 获得浏览器的语言
    Str.append("Language:");
    Str.append(Client.getMainLanguage());
    Str.append("<BR>");

    // 获得浏览器授权信息
    Str.append("Authorization:");
    Str.append(Client.getAuthorization());
    Str.append("<BR>");

    String ClientInfo = Str.toString();
    request.setAttribute("Client", ClientInfo);
    return "/client.jsp";

  }
}
TOP

Related Classes of demo.ClientServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.