Ajax上的Java过滤器

There is a single page website which for example 10 links to some forms, all of them are reloaded by using ajax(by JSON in rests).

I want to use filter for first link and redirect to another website. I implemented a simply class (extends Filter), check URL and if this is first - redirect to address XXX.

It works when I pass first-form link in browser or open in new tab but doesn't work for ajax requests.

Is there any way to use filter for this kind of requests and get redirect?