日期:2014-05-18  浏览次数:20635 次

菜鸟的超级难题 jsp中如何得到用户输入地址栏的完整信息,可能是错误的信息.

tomcat  
localhost_access_log.2007-02-08.txt可以记录访问者的输入信息,但是我想在jsp中如何得到,request能得到么?
如ie中输入http://localhost:8080/gatetransmit/sdsfdsfd

127.0.0.1   -   -   [08/Feb/2007:05:03:12   -0500]   "GET   /gatetransmit/sdsfdsfdHTTP/1.1 "   404   436   "- "   "Mozilla/4.0   (compatible;   MSIE   6.0;   Windows   NT   5.1;   SV1) "
我要的到http://localhost:8080/gatetransmit/sdsfdsfd这个信息
有可能用户输入的是http://localhost:8080/gatetransmit/saaaa
那我要得到http://localhost:8080/gatetransmit/saaaa
  String       test=request.getServerName()   +   request.getContextPath()   +   request.getServletPath()   ;  
    StringBuffer     ssurl     =     request.getRequestURL();  
用这样都得不到.
会得到tomcat出错时候默认的
http://localhost:8080/gatetransmit/index.jsp
谢谢!

------解决方案--------------------
你是想在用户输入http://localhost:8080/gatetransmit/saaaa时,但网站上没有这个文件,然后就转到错误页面,然后在错误页面上得到上一页的网址,理论上是可以的
------解决方案--------------------
恩,楼上的思路应该是可以的,如果能在错误页面获得这个地址的话~~
------解决方案--------------------
这个肯定可以的,要不然tomacat 怎么知道错了。等待高手解说:)
------解决方案--------------------
tomcat默认已经转到错误页面了,不能读取了,除非在链接时就记录当前url