Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Servlet Tomcat Example

Available as of Camel 2.7

This example is located in the examples/camel-example-servlet-tomcat directory of the Camel distribution.
There is a README.txt file with instructions how to run it.

If you use maven then you can easily package the example from the command line:

Code Block
mvn package

About

This example demonstrates how you can use Servlet to expose a http service in a Camel route.

Implementation

In the web.xml file in the src/main/webapp/WEB-INF folder the CamelServlet is defined. This is mandatory to do when using the Servlet component.

Wiki Markup
{snippet:id=e1|lang=xml|title=web.xml|url=camel/examples/camel-example-servlet-tomcat/src/main/webapp/WEB-INF/web.xml}
The route is a simple Content Based Router defined in the DSL XML as shown:
Wiki Markup
{snippet:id=e1|lang=xml|title=camel-config.xml|url=camel/examples/camel-example-servlet-tomcat/src/main/resources/camel-config.xml}

Running the example

This example runs in Apache Tomcat, so you will have to package the .war file and copy it to the webapp folder of Tomcat, which is the hot deploy folder.

There is a main page at: http://localhost:8080/camel-example-servlet-tomcat which has more instructions.
You can then use a web browser and send a request to the http://localhost:8080/camel-example-servlet-tomcat/camel/hello url.

See Also