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

求救大侠 菜鸟的超级难题 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/sdsfdsfd
你这样不行的,你的gatetransmit下有sdsfdsfd这个文件吗
------解决方案--------------------
function sslCheck(){
var url=location.href; //得到当前的地址栏的地址。

}
------解决方案--------------------
关注
------解决方案--------------------
可以实现。。
需要加过滤器。
----------
web,xml文件加上下面信息

<filter>
<filter-name> filterauthor </filter-name>
<filter-class> com.xing.servlet.AuthorFilter </filter-class>
</filter>
<filter-mapping>
<filter-name> filterauthor </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>

---------------------
这样所有的请求都会先到你加的这个过滤器里面。

过滤器里面可以通过req.getRequestURI()来得到你的连接请求。

--------
具体过滤器用法。你上网找找把。资料很多。我讲的不清楚。
------解决方案--------------------
在你的web.xml里加上这些,
<error-page>
<error-code> 404 </error-code>
<location> /error.jsp </location>
</error-page>
<error-page>
<error-code> 500 </error-code>
<location> /error.jsp </location>
</error-page>


error.jsp内容如下
<%@ page isErrorPage= "true " %>
<HTML>
<HEAD>
<TITLE> An Error Page Using the exception Object </TITLE>
<script language= "javascript ">
alert(location.href);
</script>
</HEAD>

<BODY>
<%
String test=request.getServerName() + request.getContextPath() + request.getServletPath() ;
StringBuffer ssurl = request.getRequestURL();
out.println(test);
out.println(ssurl);
out.println(request.getHeader( "referer "));
%>
<H1> An Error Page Using the exception Object </H1>
An error occurred: <%= exception.getMessage() %>
</BODY>
</HTML>
------解决方案--------------------
public final class AuthorFilter implements Filter {
private FilterConfig filterConfig = null;
private static final String CONTENT_TYPE = "text/html; charset=GB2312 ";
public void init(FilterConfig filterConfig) {