0
点赞
收藏
分享

微信扫一扫

JSP获取用户IP

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
"<%=basePath%>">

'sourceindex.jsp'

"pragma" content="no-cache">
"cache-control" content="no-cache">
"expires" content="0">
"keywords" content="keyword1,keyword2,keyword3">
"description" content="This is my page">
<!--
"stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<%
//通过Request对象的getRemoteAddr()方法获取用户IP
out.println(IP);
%>
</body>
</html>

举报

相关推荐

0 条评论