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
谢谢!
菜鸟自己先顶一下,大侠们救救!
我是想分析用户输入错误信息是什么.
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
谢谢!
菜鸟自己先顶一下,大侠们救救!
我是想分析用户输入错误信息是什么.
解决方案 »
- eclipse使用wpt开发web项目部署到别的tomcat,出现问题
- 请教网页监控高手
- 紧急求就啊!!XML文件的错误
- 关于文件的导入导出!
- 哪位能提供JSP购物网站下载
- 问题有点难,请教高手,我用一个数组保存数据库的字段名,但是无法获取 报错说Column not found 详细类容请进
- 一个jsp错误?弄了好几天了,在线等!
- tomcat服务器运行了十几天后想停止,运后shutdown.bat命令提示Error occurred during initialization of VM
- servlet传输文件问题
- 有关JavaBeans属性和事件的使用
- [请教一个问题]关于在javascript中删除文件的问题
- 炒菜鸟提问:编译时出错,提示“javax.servlet 不存在”
你这样不行的,你的gatetransmit下有sdsfdsfd这个文件吗
没有这个文件,主要是要想知道用户输入的信息是什么
没有文件是tomcat配置出错后自动转到index.jsp.
关键我是需要知道访问者在浏览器上地址栏上输入的是什么,能得到么?
谢谢关注!
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()来得到你的连接请求。--------
具体过滤器用法。你上网找找把。资料很多。我讲的不清楚。
我先试一试,要是好使马上结帖子,多谢up的兄弟们谢谢!
原来配置是:<!--
<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>
-->
<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>
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);//这句话就是。安你之前的连接跳转。 }
}