Time for action - setting up the web application bundle

This setup is composed of two steps:

  1. Specifying the Web-ContextPath OSGi manifest entry.
  2. Optionally including a WEB-INF/web.xml configuration.

Note

The preceding are the steps based on the (recently) released OSGi Service Platform Enterprise Specification 4.2 and may be updated in the Pax Web implementation by the time you read this. In the meantime, we need to use the Webapp-Context manifest entry.

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Category>sample</Bundle-Category>
<Webapp-Context>bookshelf</Webapp-Context>
<!--
<Web-ContextPath>/bookshelf</Web-ContextPath>
-->

Tip

I've included the Web-ContextPath element (commented out) in the plugin configuration for the sake of compatibility with the specifications.

Next is the web.xml file. It is located under src/main/resources/WEB-INF/. Its contents are kept to a minimum:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Bookshelf Web-app</display-name>
</web-app>

We don't need more.

What just happened?

Based on the bundle manifest entry (and the web.xml file), the Web Container will identify this bundle as a web application bundle and deploy its contents under the given context path. Once deployed, JSP content will be served under http://localhost:8080/bookshelf/.

So let's finish our preparation work and get to the JSP side of things.

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

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