Getting Started with DynamicServlet-Bridge Print

If you have a typical Java Web Application and you want to be able to deploy servlets dynamically but you don't have an OSGi Application embedded in the Web Application, then you need to follow these steps:

  • Download dynamic-servlet-bridge-with-da_launcher.war and extract it to the root directory of your Web Application. Just make sure not to overwrite your web.xml file if you need to keep it.
  • If you kept your web.xml then make sure that the contents of the web.xml file in the downloaded archive be copied to your web.xml file.
  • The downloaded web.xml contains one servlet which acts as a bridge. You can use this servlet as a template for creating Bridge Servlets. If you didn't read the "How DynamicServlet-Bridge works?" section of the overview, then please make sure to read it to understand how Bridge Servlets match OSGi Servlet Services.
  • Make sure that every servlet you have in application's bundles that you want requests to be forwarded to, is registered as an OSGi Service that implements the javax.servlet.Servlet interface.
  • Deploy the bundles that contain your servlets by copying them to the “/WEB-INF/da-launcher/bundles/application-bundles” directory.

Now, you have a Web Application which runs an OSGi-based application inside of it that provides OSGi Servlet services to Bridge Servlets. Bridge Servlets will forward requests to mapped OSGi Servlet Services. If anything goes wrong you can always refer to the application in the “Example” section and compare with your application.

If you have a Java Web Application which already runs an OSGi Environment inside of it, then you need to follow these steps:

  • Download dynamic-servlet-bridge.war and extract it to the root directory of your Web Application. Just make sure not to overwrite your web.xml file if you need to keep it.
  • If you kept your web.xml then make sure that the contents of the web.xml file in the downloaded archive be copied to your web.xml file.
  • The downloaded web.xml contains one servlet which acts as a bridge. You can use this servlet as a template for creating Bridge Servlets. You can use this servlet as a template for creating Bridge Servlets. It's critical to fill the servlet parameter “bundle-context-attribute-name” which should contain the name of Servlet Context Attribute that has the reference to the Bundle Context of your OSGi Environment.
  • Make sure that every servlet you have in application's bundles that you want requests to be forwarded to, is registered as an OSGi Service that implements the javax.servlet.Servlet interface.

When you will run your Web Application and send requests to the URL handled by the Bridge Servlet, the requests will be handled by the mapped OSGi Servlet Services that you registered in your bundles.