Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A simple servlet in this app reads the two request parameters delay and code.  It sleeps for the amount of time specified in the delay. If the code is 200, it serves a file called dummy.html. For the status code 500, it does a divide by zero to throw a servlet exception. For other status codes, it sets the appropriate response code in the response.sendError(). It then returns. This simulates varous response times and return status codes from an external app. This app can be run on any other server and machine.

Configuring the server

Install a geronimo server with tomcat webcontainer and start it. Log onto the console by using system/manager as your credentials. Click on the "Web Server" link on the left hand navigation frame. Under "Add new:" section, click on "Tomcat NIO HTTP connector".  Specify a uniquename for the connector and take all the default values. Save this configuration. Your new connector must be listed in the Network Listeners.

Now delete the TomcatWebConnector in the Network Listeners list so that all connections are made to the new Tomcat NIO HTTP connector.

Building the sample

  1. Download the zip file which contains both the apps discussed above.
  2. Unzip the file into a directory of your choice, say samples.
  3. cd into samples\async-http directory\http-local-app\src\main\webapp\WEB-INF directory.
  4. edit the web.xml there and change the value of the <remoteUrl> initi-param. This should be set to the machine where your remote app will be deployed.
  5. cd back to async-http directory.
  6. execute mvn. This will build the 2 WARs.

Running the sample

  1. Deploy samples\async-http directory\http-local-app\target\http-local-app-2.0-SNAPSHOT.war on the Geronimo server we configured earlier using either the consoleor the command line
    Code Block
    $geronimo_home/bin>./deploy.sh deploy http-local-app-2.0-SNAPSHOT.war
    
  2. Deploy samples\async-http directory\http-remote-app\target\http-remote-app-2.0-SNAPSHOT.war on any server on the remote machine.
  3. Point your browser to http://localhost:8080/localApp/async. If you wish to override the remoteUrl set in the <init-param> of the web.xml, you may pass it as a request param (http://localhost:8080/localApp/async?remoteUrl=http://foo:8080Image Removed)
  4. You should see either a dummy html or one of the popular HTTP errors.