AdminFilter.java.svn-base
资源名称:cindyblog.rar [点击查看]
上传用户:cdpainuo
上传日期:2022-07-12
资源大小:5257k
文件大小:1k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.appspot.cindyblog.common;
- 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;
- import javax.servlet.http.HttpServletResponse;
- public class AdminFilter implements Filter {
- public void doFilter(HttpServletRequest request, HttpServletResponse response,
- FilterChain chain) throws IOException, ServletException {
- }
- public void init(FilterConfig filterConfig) throws ServletException {
- }
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain arg2) throws IOException, ServletException {
- HttpServletRequest h = (HttpServletRequest) request;
- HttpServletResponse r = (HttpServletResponse) response;
- String username = (String) h.getSession().getAttribute("username");
- if(username == null){
- r.sendRedirect("/");
- }else{
- arg2.doFilter(request, response);
- }
- }
- public void destroy() {
- // TODO Auto-generated method stub
- }
- }