Neither of these things have anything to do with where the servlet is contained. I agree with @davidjgonzalez that putting (non-trivial) Java code in the repository is a pattern to be avoided (despite the fact that it is done in the product). If only because it makes unit testing impossible.

Mostly I still don't see how this servlet is ever invoked.