tomcat 
localhost_access_log.2007-02-08.txt可以记录访问者的输入信息,但是我想在jsp中如何得到,request能得到么?
如ie中输入http://localhost:8080/gatetransmit/sdsfdsfd127.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
谢谢!
菜鸟自己先顶一下,大侠们救救!
我是想分析用户输入错误信息是什么.

解决方案 »

  1.   

    http://localhost:8080/gatetransmit/sdsfdsfd
    你这样不行的,你的gatetransmit下有sdsfdsfd这个文件吗
      

  2.   

    谢谢liaohaiying(大菜) 
    没有这个文件,主要是要想知道用户输入的信息是什么
    没有文件是tomcat配置出错后自动转到index.jsp.
    关键我是需要知道访问者在浏览器上地址栏上输入的是什么,能得到么?
    谢谢关注!
      

  3.   

    function sslCheck(){
    var url=location.href;   //得到当前的地址栏的地址。

    }
      

  4.   

    可以实现。。
    需要加过滤器。
    ----------
    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()来得到你的连接请求。--------
    具体过滤器用法。你上网找找把。资料很多。我讲的不清楚。
      

  5.   

    谢谢yunxiang(无名) ( )
    我先试一试,要是好使马上结帖子,多谢up的兄弟们谢谢!
      

  6.   

    yunxiang(无名) ( )
    原来配置是:<!--
        <filter>
            <filter-name>ssi</filter-name>
            <filter-class>
              org.apache.catalina.ssi.SSIFilter
            </filter-class>
            <init-param>
              <param-name>contentType</param-name>
              <param-value>text/x-server-parsed-html(;.*)?</param-value>
            </init-param>
            <init-param>
              <param-name>debug</param-name>
              <param-value>0</param-value>
            </init-param>
            <init-param>
              <param-name>expires</param-name>
              <param-value>666</param-value>
            </init-param>
            <init-param>
              <param-name>isVirtualWebappRelative</param-name>
              <param-value>0</param-value>
            </init-param>
        </filter>
    -->
      <!-- ==================== Built In Filter Mappings ====================== -->  <!-- The mapping for the SSI Filter -->
    <!--
        <filter-mapping>
            <filter-name>ssi</filter-name>
            <url-pattern>*.shtml</url-pattern>
        </filter-mapping>
    -->
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1),127.0.0.1,localhost:8080测试:http://localhost:8080/gatetransmit/index.jsp,20070208230336
    按照yunxiang(无名) 的试验,不行得到如上http://localhost:8080/gatetransmit/index.jsp
    而且没法正常跳转了.
    <!--
        <filter>
            <filter-name>filterauthor</filter-name>
            <filter-class>
              com.xing.servlet.AuthorFilter
            </filter-class>
            <init-param>
              <param-name>contentType</param-name>
              <param-value>text/x-server-parsed-html(;.*)?</param-value>
            </init-param>
            <init-param>
              <param-name>debug</param-name>
              <param-value>0</param-value>
            </init-param>
            <init-param>
              <param-name>expires</param-name>
              <param-value>666</param-value>
            </init-param>
            <init-param>
              <param-name>isVirtualWebappRelative</param-name>
              <param-value>0</param-value>
            </init-param>
        </filter>
    -->
      <!-- ==================== Built In Filter Mappings ====================== -->  <!-- The mapping for the SSI Filter -->
    <!--
        <filter-mapping>
            <filter-name>filterauthor</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    -->
    和如下都试过不行
    <!--
        <filter>
            <filter-name>filterauthor</filter-name>
            <filter-class>
              com.xing.servlet.AuthorFilter
            </filter-class>
     
        </filter>
    -->
      <!-- ==================== Built In Filter Mappings ====================== -->  <!-- The mapping for the SSI Filter -->
    <!--
        <filter-mapping>
            <filter-name>filterauthor</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    -->
      

  7.   

    在你的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>
      

  8.   

    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) {
            this.filterConfig = filterConfig;
        }
         public void doFilter(ServletRequest request, ServletResponse response,
                FilterChain chain)  throws IOException, ServletException {
            HttpServletRequest req = (HttpServletRequest) request;
            chain.doFilter(request, response);//这句话就是。安你之前的连接跳转。    }
    }