javatomcattomcat8ajp

programmatically know from which connector the request made in tomcat


I have multiple connectors configured in tomcat 8.5.23 (http, https and ajp). Is there any way to know programmatically from which connector the request is coming from. One detection i can do is based on the port but wanted to know is there any easier way to know the connector type programmatically.

Thanks.


Solution

  • If your request is an instance of org.apache.catalina.connector.Request you can cast it and call the getConnector method to get the associated connector.