servlet請求處理方法有哪些 用servlet如何獲取IP?
用servlet如何獲取IP?區(qū)域設(shè)置語言類型=請求.getLocale()//獲取用戶語言字符串localip=請求.getLocalAddr()//獲取本地IPint localport=請求.g
用servlet如何獲取IP?
區(qū)域設(shè)置語言類型=請求.getLocale()//獲取用戶語言
字符串localip=請求.getLocalAddr()//獲取本地IP
int localport=請求.getLocalPort()//獲取本地端口
字符串localname=請求.getLocalName()//獲取本地計(jì)算機(jī)的名稱
字符串remoteip=請求.getRemoteAddr()//獲取客戶端IP
int remotePort=請求.getRemotePort()//獲取客戶端的端口號
字符串servername=請求.getRemoteHost()//獲取遠(yuǎn)程計(jì)算機(jī)的名稱系統(tǒng)輸出打?。ā罢Z言類型->”語言類型)系統(tǒng)輸出打?。╨ocalName“”服務(wù)器名)系統(tǒng)輸出打?。╨ocalIp“:”localPort“”remoteIp“:”remotePort)}public void doGet(HttpServletRequest request,HttpServletResponse response)
拋出ServletException,IOException{
String requestURL=request.getRequestURL(). Tostring()//獲取參數(shù)以外的地址信息
string requesturi=請求.getRequestURI()
字符串queryString=請求.getQueryString()
系統(tǒng)輸出打?。ā罢埱蟮牡刂?>”請求的URL)系統(tǒng)輸出打印(“請求地址后的信息->”查詢字符串)}