求救:如何取得IE地址栏中的地址!up 都有分,谢谢!

musclecn 2004-09-22 09:37:21
在地址栏中输入一段网址,
使用request.getRequestURL(),取得的却是机器名
在以前在没有装tomcat的情况下使用request.getRequestURL()可以取得到地址,现在取的是空.
使用javascript
<SCRIPT>
document.write (windows.location);
</SCRIPT>
得到的地址是正确的

问有什么好的办法用jsp取得地址栏中的地址?
...全文
324 22 点赞 打赏 收藏 举报
写回复
22 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
chashui 2004-09-24
up
  • 打赏
  • 举报
回复
victorylj 2004-09-24
关注ing
  • 打赏
  • 举报
回复
dlxu 2004-09-24
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort() + request.getRequestURI()
前面得到server的地址,中间得到端口号,最后得到URL,一加起来就可以了
  • 打赏
  • 举报
回复
java_dd 2004-09-24
out.println("<br>Protocol: " + request.getProtocol() + "");
out.println("<br>Scheme: " + request.getScheme() + "");
out.println("<br>Server Name: " + request.getServerName() + "" );
out.println("<br>Server Port: " + request.getServerPort() + "");
out.println("<br>Protocol: " + request.getProtocol() + "");
out.println("<br>Server Info: " + getServletConfig().getServletContext().getServerInfo() + "");
out.println("<br>Remote Addr: " + request.getRemoteAddr() + "");
out.println("<br>Remote Host: " + request.getRemoteHost() + "");
out.println("<br>Character Encoding: " + request.getCharacterEncoding() + "");
out.println("<br>Content Length: " + request.getContentLength() + "");
out.println("<br>Content Type: "+ request.getContentType() + "");
out.println("<br>Auth Type: " + request.getAuthType() + "");
out.println("<br>HTTP Method: " + request.getMethod() + "");
out.println("<br>Path Info: " + request.getPathInfo() + "");
out.println("<br>Path Trans: " + request.getPathTranslated() + "");
out.println("<br>Query String: " + request.getQueryString() + "");
out.println("<br>Remote User: " + request.getRemoteUser() + "");
out.println("<br>Session Id: " + request.getRequestedSessionId() + "");
out.println("<br>Request URI: " + request.getRequestURI() + "");
out.println("<br>Request URL: " + request.getRequestURL() + "");
out.println("<br>Servlet Path: " + request.getServletPath() + "");
out.println("<br>Accept: " + request.getHeader("Accept") + "");
out.println("<br>Host: " + request.getHeader("Host") + "");
out.println("<br>Referer : " + request.getHeader("Referer") + "");
out.println("<br>Accept-Language : " + request.getHeader("Accept-Language") + "");
out.println("<br>Accept-Encoding : " + request.getHeader("Accept-Encoding") + "");
out.println("<br>User-Agent : " + request.getHeader("User-Agent") + "");
out.println("<br>Connection : " + request.getHeader("Connection") + "");
out.println("<br>Cookie : " + request.getHeader("Cookie") + "");
out.println("<br>Created : " + session.getCreationTime() + "");
out.println("<br>LastAccessed : " + session.getLastAccessedTime() + "");

扩展了一些,以后可能会用到。
  • 打赏
  • 举报
回复
kuzhu456 2004-09-24
up too
  • 打赏
  • 举报
回复
chan2chen 2004-09-24
up
  • 打赏
  • 举报
回复
jein 2004-09-24
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()
+ request.getRequestURI()
  • 打赏
  • 举报
回复
panzi667 2004-09-24
关注中~~~~~~~·
  • 打赏
  • 举报
回复
musclecn 2004-09-23
thank !
  • 打赏
  • 举报
回复
XIHSHI 2004-09-23
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()
+ request.getRequestURI()
  • 打赏
  • 举报
回复
dlglmf 2004-09-23
up
  • 打赏
  • 举报
回复
tibhar 2004-09-23
up
  • 打赏
  • 举报
回复
guojiafuzhuxi 2004-09-23
UPUPUPUPUIPPUIP,
  • 打赏
  • 举报
回复
fantasyCoder 2004-09-22
request.getRequestURL();这个方法可直接得到参数以外的所有URL
返回的是一个StringBuffer

若你同时希望拿到URL参数-值
再拼接上
request.getQueryString();
  • 打赏
  • 举报
回复
yuyong_try 2004-09-22
支持楼上
  • 打赏
  • 举报
回复
fantasyCoder 2004-09-22
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()
+ request.getRequestURI()

效果等同与

window.location
  • 打赏
  • 举报
回复
TinyJimmy 2004-09-22
Inetaddress 转换
  • 打赏
  • 举报
回复
sw47 2004-09-22
request.getServerName()+":"+request.getServerPort() +request.getRequestURI()
  • 打赏
  • 举报
回复
sw47 2004-09-22
request.getServerName()+request.getRequestURI()
  • 打赏
  • 举报
回复
anningha 2004-09-22
up~~
  • 打赏
  • 举报
回复
加载更多回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-22 09:37
社区公告
暂无公告