views:

100

answers:

1

I'm trying to create a filter, for some reason I am not seeing autocompletion when I create a class that implements a Filter.

When I type:

import javax.servlet

IDEA doesn't seem to pickup the namespace.

Is this a separate .jar that I have to setup in maven?

Update

My filter mappings look like:

<filter>

        <filter-name>performancefilter</filter-name>
        <filter-class>com.blah.core.filters.PerformanceFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>performancefilter</filter-name>
        <url-pattern>/</url-pattern>
    </filter-mapping>
+3  A: 

I'm trying to create a filter, for some reason I am not seeing autocompletion when I create a class that implements a Filter.

Then you probably don't have the servlet-api defined as dependency in your pom.xml. Assuming you're using Servlet 2.5, your pom.xml should declare:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
Pascal Thivent
thanks this worked! btw, where can I see a simple skeleton of a filter with web.xml example?
Blankman
@Blankman [The Essentials of Filters](http://www.oracle.com/technetwork/java/filters-137243.html) is a good start (see [this](http://www.javabeat.net/articles/print.php?article_id=100) for the small changes since then).
Pascal Thivent
funny, when I added the <filter></filter> xml in the web.xml, my </web-app> xml node is underlined in red (IDEA), not sure why. It says content element <web-app> must match. It does match! removing teh <filter>..</filter> tags gets rid of the error.
Blankman
@Pascal, I updated my question with my filter xml part.
Blankman
@Blankman Can't say without seeing all the relevant parts from the web.xml (except that you should probably use a wildcard in the url-pattern). Maybe open another question?
Pascal Thivent