How to block requests from robots

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to block requests from robots

Fabian Gonzalez

I want to block requests from some aggresive bots and
spiders to my site.

So far I've tried implementing AbstractHttpHandler and
providing the following handler() method:

    public void handle(String pathInContext, String
pathParams, HttpRequest request, HttpResponse
response) throws HttpException, IOException {
(ignoreAddresses.contains(request.getRemoteAddr())) {
        } // if //

        String agent =
        for (int i = 0; i < ignoreAgents.length; i++)
            String ignoreString = ignoreAgents[i];
            if (agent.contains(ignoreString)) {
            } // if //
        } // for //
    } // log //

This way I can filter by IP addres or by user agent.

I then add the handler to the web application context
by adding the following to my XML configuration file:

  <Call name="getContext">
     <Call name="addHandler">
         <Set name="ignoreAgents">
           <Array type="String">

However, this doesn't seem to do anything. My guess is
that it doesn't work because a previously registered
handler handles the request, and my filter thus does

Any ideas on how I can get this working properly?


- Fabian

Fine Art Prints & Stock Images

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play:
jetty-discuss mailing list
[hidden email]