Previous Topic

Next Topic

Book Contents

Book Index

Notes

To compile a servlet, you need the archive with the Java Servlet API classes and a path to it in your classpath. To run a servlet successfully with the HTTP Service, include the javax.servlet and javax.servlet.http packages in the Import-Package header of the bundle manifest.

If you implement the javax.servlet.SingleThreadModel interface, you should supply a default constructor of the implementation class. This is necessary, because when a request to such a servlet comes, the Servlet Engine makes a new instance of the servlet to service the request using this constructor.

Bundle developers who register resources and servlets with the HTTP Service should consider that when stopped, the HTTP Bundle unregisters all aliases. Such bundles should subscribe service listeners for starting events for the HTTP Bundle so that they can register their aliases again. If you unregister aliases after the HTTP Bundle has stopped, you should catch the Exception that is thrown in this case. If the HTTP Bundle is updated, all registered aliases are removed. Therefore, if you try to force unregistration of aliases, an IllegalArgumentException is thrown.

If you call BundleContext.unget on an HTTP Service reference, the latter unregisters all resources that your bundle registered.