# Integrating Jetty and JOnAS

Jetty is an open source HTTP server and Servlet container that is an implementation of the Java Servlet 2.3 and JSP 1.2 specifications. Jetty is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies.

Since JOnAS 2.6, JOnAS provides a full J2EE application server, Jetty may be used with JOnAS as Web container. This functionnality is set up via the JOnAS web container service.
At this time Tomcat 4.1.x and Jetty 4.2.x are supported as implementation of JOnAS web container service.
Note that in earlier versions of JOnAS a service jetty was provided. In the JOnAS J2EE server you will be able to run your beans inside EJB containers via the ejb service or ear service while you will be able to run your servlets or JSPs via the web container service or ear service. JOnAS will be used to run your beans inside EJB containers while Jetty will be used to run your servlets or JSPs. Inside these servlets or JSPs, you will be allowed to access remotely beans inside the JOnAS EJBServer.

For the cases where security is needed, Jetty will be used also for user authentication. Refer to the security in Jetty for more information on how to use security with JOnAS and Jetty.

Here after are described the following steps to configure JOnAS and Jetty to make them working together.

1. Installing Jetty
2. Configuring Jetty for JOnAS
3. Structuring your Web Application

## Installing Jetty

1. Download Jetty at Jetty site
   At this time Jetty 4.2.2 and more family has been tested successfully with JOnAS.
2. Install Jetty by unzipping the download file and put it in a specific directory. This directory will be referred as $JETTY_HOME.
   In the $JONAS_ROOT/config directory, there is the Jetty config file : jetty.xml.
3. On Windows, set the JAVA_HOME variable in your environment to your JDK installation directory.

## Configuring Jetty for JOnAS

Since JOnAS 2.6, a new JOnAS service web is provided for launching a servlet container inside the JOnAS JVM.
At this time, two implementations of this service are provided.

- First implementation is Jetty 4.2.x which is used as servlet container.
- Second implementation is with web container service Tomcat 4.1.x

All you have to do is to add web in the `jonas.services` property of `jonas.properties` file and to set the `jonas.service.web.class` property of `jonas.properties` file to:

- `org.objectweb.jonas.web.jetty.JettyJWebContainerServiceImpl`

Then you configure Jetty as usual by updating if needed the `$JONAS_ROOT/config/jetty.xml`.

You can set the Jetty port with putting in the $JAVA_OPTS var, the command line : -Djetty.port=`<your port number>`. This will ovveride the property of the jetty.xml file. For more information have a look at Jetty configuration documentation

## Structuring your Web Application

How to use servlets and JSPs is explained in the Developing Web Components or J2EE Application Programmer's Guide chapters of the online JOnAS documentation.