cancel
Showing results for 
Search instead for 
Did you mean: 

Servlet Filter

joachimvanpraet
Active Participant
0 Kudos

Hi,

I'm trying to use a servlet filter.

I created this class:


package com.test 

import java.io.IOException;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;

public class myFilter implements Filter{

	public void destroy() {
		System.err.println("DESTROY FILTER!!");
	}

	public void doFilter(
		ServletRequest request,
		ServletResponse response,
		FilterChain chain)
		throws IOException, ServletException {
		
                      System.err.println("DO FILTER!!");
		
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		System.err.println("INIT FILTER!!");
	}

}

this is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
	<filter>
		<filter-name>myFilter</filter-name>
		<display-name>My filter</display-name>
		<filter-class>com.test.myFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>myFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
</web-app>

When I deploy this filter, I can see the "DESTROY FILTER!!" en "INIT FILTER!!" in the logfile.

Then I clicked some links in the portal, but there is no "DO FILTER!!" int he logfile.

Can sombody help me?

thanks,

Joachim

Accepted Solutions (0)

Answers (1)

Answers (1)

joachimvanpraet
Active Participant
0 Kudos

Is there someone who can help me?

blog about filter: [/people/guru.subramanianb/blog/2005/02/17/understanding-java-filters|/people/guru.subramanianb/blog/2005/02/17/understanding-java-filters]

This filter should execute for each request on the portal server, right?

What's wrong here? There is no "DO FILTER!!" in the default trace...