How to I get the clients IP address in a handler?
That’s a similar question than the question on initializing handlers. The main difference is, that in this case you want to initialize the handler with any request. In other words, you might achieve the goal by creating a RequestProcessorFactoryFactory, that provides the necessary details. However, there is an easier solution, which we will demonstrate here: Use a ThreadLocal. The class ThreadLocal allows to create information at some point in the source code and use this information at one or more completely different and decoupled places. The only assumption is, that you are in the same thread. This is exactly our situation: We create the information when processing of the XML-RPC request starts and read it within the handler. In the example below, you’d obtain the clients IP address by writing ClientInfoServlet.getClientIpAddress().