Servlet2.java~1~
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package filter5;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.io.*;
- import java.util.*;
- public class Servlet2 extends HttpServlet implements Filter {
- private FilterConfig filterConfig;
- //Handle the passed-in FilterConfig
- public void init(FilterConfig filterConfig) {
- this.filterConfig = filterConfig;
- }
- //Process the request/response pair
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) {
- try {
- request.setAttribute("data","hello");
- filterChain.doFilter(request, response);
- }
- catch(ServletException sx) {
- filterConfig.getServletContext().log(sx.getMessage());
- }
- catch(IOException iox) {
- filterConfig.getServletContext().log(iox.getMessage());
- }
- }
- //Clean up resources
- public void destroy() {
- }
- }