用Java设计一个TCP的代理服务器。
客户端应用程序如IE,设置我的程序为代理服务器,访问www.sina.com.cn
那么客户端发送来的Request请求中的目的地址是我的IP地址,我怎么知道客户端要访问的是www.sina.com.cn,就是说客户端将其最终访问的地址写在哪了?

解决方案 »

  1.   

    request详解
    1) getParameter(String name) 一般用它读取表单中参数
    (2) getProtocol() 获取客户端向服务器端传送数据所依据的协议名称。
    (3)getRemoteAddr() 获取客户端的IP地址。 
    (4)getRemoteHost() 获取客户端的名字。 
    (5)getServerName() 获取服务器的名字。
    (6)getServerPort() 获取服务器的端口号。
    (7)getHeader()获取客户端的浏览器类型。
    1 object getAttribute(String name) 返回指定属性的属性值 
    2 Enumeration getAttributeNames() 返回所有可用属性名的枚举 
    3 String getCharacterEncoding() 返回字符编码方式 
    4 int getContentLength() 返回请求体的长度(以字节数) 
    5 String getContentType() 得到请求体的MIME类型 
    6 ServletInputStream getInputStream() 得到请求体中一行的二进制流 
    7 String getParameter(String name) 返回name指定参数的参数值 
    8 Enumeration getParameterNames() 返回可用参数名的枚举 
    9 String[] getParameterValues(String name) 返回包含参数name的所有值的数组 
    10 String getProtocol() 返回请求用的协议类型及版本号 
    11 String getScheme() 返回请求用的计划名,如:http.https及ftp等 
    12 String getServerName() 返回接受请求的服务器主机名 
    13 int getServerPort() 返回服务器接受此请求所用的端口号 
    14 BufferedReader getReader() 返回解码过了的请求体 
    15 String getRemoteAddr() 返回发送此请求的客户端IP地址 
    16 String getRemoteHost() 返回发送此请求的客户端主机名 
    17 void setAttribute(String key,Object obj) 设置属性的属性值