JSP显示服务器地址的问题

SHY1977 2006-12-11 01:01:58
请高人指点一下,如何显示当前访问JSP页面的IP,最好是纯粹的JSP代码,谢谢
...全文
242 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
SHY1977 2006-12-11
  • 打赏
  • 举报
回复
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<table border="1">
<tr>
<th>
Header
</th>
<th>
Value
</th>
</tr>

<c:forEach var="entry" items="${header}">
<tr>
<td>
${entry.key}
</td>
<td>
${entry.value}
</td>
</tr>
</c:forEach>
</table>
=====================
上面可以显示全部的表头信息,但如果要分解显示其中一个,该怎么做呢?
liaohaiying 2006-12-11
  • 打赏
  • 举报
回复
显示当前访问JSP页面的IP:request.getRemoteAddr()
BBXXL 2006-12-11
  • 打赏
  • 举报
回复
访问端 request.getRemoteAddr()
应用服务器 request.getServerName()
learningjsp 2006-12-11
  • 打赏
  • 举报
回复
request.getServerName();
dyw31415926 2006-12-11
  • 打赏
  • 举报
回复
保存为showIp.jsp
dyw31415926 2006-12-11
  • 打赏
  • 举报
回复
<%@ page contentType= "text/html;charset = UTF-8"%>
<%@ page import = "java.net.*" %>
<html>
<title>
show Ip
</title>
<body>
<form action ="showIp.jsp" >
要查找的服务器:<input type = "textarea" name ="server" value="" />
<br/>
<input type ="submit" name ="submit"/>
<%
String server = request.getParameter("server");
if (server != null)
{
%>
<br/>
你要查找的服务器ip是:
<%
try
{
String s = InetAddress.getByName(server).toString();
out.println(s+ "<br/>");
}
catch ( UnknownHostException e)
{
out.println("无法解析<br>");
}
%>
你自己的ip是: <%= request.getRemoteAddr()%>
<% } %>
</form>
</body>
</html>
siemenew 2006-12-11
  • 打赏
  • 举报
回复
显示客户端还是服务器的地址?
jicken_woo 2006-12-11
  • 打赏
  • 举报
回复
纯jsp代码?
关注。。。
学习一下。。

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧