limq

rainman
随笔 - 17, 文章 - 1, 评论 - 98, 引用 - 1
数据加载中……

Servlet 路径

首先建立一个测试页面:path.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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
请求断口号: 8080
Context路径: /WebModule1
Servlet路径: /path.jsp
URI路径: /WebModule1/path.jsp
查询字串: name=justin&nick=caterpillar

使用者主?CIP: 127.0.0.1
1490

posted on 2005-03-01 23:29 limq 阅读(1780) 评论(0)  编辑  收藏


标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
 
相关链接:
网站导航: