Search code examples
tomcatserverwarweb-deploymentcatalina

How to tell Apache Tomcat who must handle received data?


I'm using the newest Apache Tomcat (9.0.16), with newest Java / OpenSSL. I got a WAR file with a server application from NEXUSe2e.org.

I'm able to send a secure message to a service. After a while someone sends a secure reply message as a new https message.

In the logging, I can see that this message is decrypted by TomCat. It is detected that this is a new SOAP action: ebXML.

This is done, using the following connectors in file %catalina_home%\conf\server.xml

<Connector
  port="443"
  protocol="org.apache.coyote.http11.Http11AprProtocol"
  redirectPort="8443"/>

<Connector
  port="8443"
  protocol="org.apache.coyote.http11.Http11AprProtocol"

  SSLEnabled="true"
  secure="true"
  scheme="https"

  defaultSSLHostConfigName="_default_">
  <SSLHostConfig 
    hostName="_default_"
    certificateVerification="required"

    <Certificate
      certificateChainFile="conf\Certificates\TrustedCertificates.pem"
      certificateFile="conf\Certificates\... .crt"
      certificateKeyFile="conf\Certificates\... .private.key"/>
  </SSLHostConfig>
</Connector>

When the data has been correctly decrypted, it has to go to my server code (NEXUSe2e). How does TomCat know who must handle the data?

  • Does TomCat actively send the received data to the server. Is it somewhere in the configuration file who is expecting the data?
  • Is the server regularly polling to see if data has been received?

Solution

  • Tomcat knows which application will handle your request by looking at the URL you have requested, and check if there is any context matching. There is no waiting or polling, things are chained automatically.

    In your case you are just copying a war file in the webapps directory, this is called Automatic Application Deployment. There are other ways to configure a context but it's nice to keep things simple while it is sufficient.

    Things are a little bit more complicated if you are using Virtual Hosts, as Tomcat would start by checking what domain name you requested, and then check which context is concerned.