1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
public class Filtre implements Filter{
private static String traitement = "oui";
private static String pageRedirection;
public void destroy() {
this.destroy();
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
if(traitement.equals("oui")){
filterChain.doFilter(request, response);
}else{
request.getRequestDispatcher("/"+pageRedirection+".jsp").forward(request,response);
}
}
public void init(FilterConfig filterConfig) throws ServletException {
//ServletContext sc = filterConfig.getServletContext();
}
public static String getTraitement() {
return traitement;
}
public static void setTraitement(String traitement) {
Filtre.traitement = traitement;
}
public static String getPageRedirection() {
return pageRedirection;
}
public static void setPageRedirection(String pageRedirection) {
Filtre.pageRedirection = pageRedirection;
}
} |
Partager