文件名称:Filter_Listener相信代码使用
文件大小:17KB
文件格式:ZIP
更新时间:2016-04-17 08:01:43
filter listener 代码详解
package com.chinasofti.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * Servlet Filter implementation class MyFilter */ public class MyFilter implements Filter { /** * Default constructor. */ public MyFilter() { // TODO Auto-generated constructor stub } /** * @see Filter#destroy() */ public void destroy() { // TODO Auto-generated method stub } /** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest reque=(HttpServletRequest) request; System.out.println("进行合法验证!!"); if(null==reque.getHeader("Referer")){ request.setAttribute("message", "你进行了不合法的操作!!!"); request.getRequestDispatcher("error.jsp").forward(request, response); 里面有更详细的代码。。。
【文件预览】:
Filter_Listener
----.project(1KB)
----.settings()
--------.jsdtscope(503B)
--------org.eclipse.wst.common.component(475B)
--------org.eclipse.jdt.core.prefs(395B)
--------org.eclipse.wst.common.project.facet.core.xml(345B)
--------org.eclipse.wst.jsdt.ui.superType.container(49B)
--------org.eclipse.wst.jsdt.ui.superType.name(6B)
----src()
--------com()
----build()
--------classes()
----WebContent()
--------page()
--------WEB-INF()
--------index.jsp(1KB)
--------META-INF()
----.classpath(833B)