How to find actual Tomcat instance in a cluster
It is common that in a cluster we have to find out which Tomcat instance is used so that we can monitor the log files of that particular server only. When Tomcat is used as the application server, normally load balancing is done using Apache JK connector (mod_jk). JK connector adds name of actual instance to JSESSIONID cookie so that the connector can know how to route the request to the server which created the session. This works only when sticky session is used. When sticky session is not used, name of actual server is not appended to cookie and request is send to a server picked based on the load on each server. In this case, it is very difficult to identify actual Tomcat server. When sticky session is not used, the solution I can think of is to use a filter that will set a cookie with a value that identifies unique name of the Tomcat instance. This filter should have configuration option to disable enable this cookie based on a configuration. Any changes to the configurati...