首先建立一個測試頁面:path.jsp<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>無標題文檔</title></head>
<body>請求服務器:<%= request.getServerName() %><br>使用協議:<%= request.getProtocol() %><br>請求方法:<%= request.getMethod() %><br>請求斷口號:<%= request.getServerPort() %><br>Context路徑:<%= request.getContextPath() %><br>Servlet路徑:<%= request.getServletPath() %><br>URI路徑:<%= request.getRequestURI() %><br>查詢字串:<%= request.getQueryString() %><br><br>使用者主機IP:<%= request.getRemoteAddr() %><br>
<%= request.getRemotePort() %></body></html>再用一下方式測試:http://localhost:8080/WebModule1/path.jsp?name=justin&nick=caterpillar結果為:請求服務器: localhost使用協議: HTTP/1.1請求方法: GET請求斷口號: 8080Context路徑: /WebModule1Servlet路徑: /path.jspURI路徑: /WebModule1/path.jsp查詢字串: name=justin&nick=caterpillar使用者主?CIP: 127.0.0.11490
posted on 2005-03-01 23:29 limq 閱讀(4579) 評論(1) 編輯 收藏
Powered by: BlogJava Copyright © limq