Chapter 13. Improving the Graphics

In Chapter 11, How about a Graphical Interface?, we've implemented a servlet-based graphical user interface, giving web access to our bookshelf service. However, as you must have noticed, writing servlets for generating HTML is tedious. One quickly finds it useful to move to JSP.

In this chapter, we will look at OSGi Web Containers, opening the door to the world of web applications. We'll look at how to use a Web Container to register JSP resources by implementing the bookshelf-webapp bundle.

You will learn about the following:

  • Web Containers and their use in the context of an OSGi framework
  • Pax Web, an Http Service extension that provides Web Containers
  • How to install Pax Web to our local Felix instance

You will also:

  • Create the bookshelf-webapp bundle and implement it with JSP
  • Learn how to register the JSPs with the Web Container
  • Learn how to get a service reference from the JSP code

So let's get started with Web Containers.

OSGi Web Containers

The OSGi specifications are in continuous evolution to meet the market needs. As a result of recent interaction that has gone on between members from OSGi and SpringSource teams, concepts around the support for web applications, and their integration in a simple manner in an OSGi framework have been compiled, and OSGi Web Containers were introduced in the OSGi Service Platform Enterprise Specification.

The idea behind a Web Container is to extend on the Http Service functionality to allow for the registration of additional content such as JSPs, registration of filters to the Http Service namespace, as well as the ability to react to lifecycle changes in the context. In our case, for example, we'll register resources (stylesheets) and JSPs.

Another goal would be to simplify the deployment of Web Application Bundles (WABs) by specifying a Web-ContextPath header in the manifest.

There are a few bundles out there that provide Web Container services. A good implementation is SpringSource's Spring dm Server (SpringSource is a division of VMware), which is the reference implementation of the specification. For the relative ease of installation and configuration, we'll use Pax Web for this example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.233