Servlet API Library

This module (isis-module-servletapi) provides access to various elements of the Servlet API, namely the ServletContext, the HttpServletRequest and the HttpServletResponse.

For each of these APIs a corresponding "provider" domain service exists; for example ServletContextProvider service provides access to the ServletContext.

This module is only available for Wicket viewer, not the REST API.

Screenshots

The module’s functionality can be explored by running the quickstart with example usage using the org.incode.domainapp.example.app.modules.ExampleDomLibServletApiAppManifest.

A home page is displayed when the app is run:

010 install fixtures

The demo object has all of the various "provider" domain services injected into it. It uses the ServletContextProvider and the HttpServletRequestProvider services to simply show the servlet context name and user’s locale:

020 servlet and request

To demonstrate the use of the HttpServletResponseProvider, the demo object provides an "addHeader" action:

030 response

When invoked, this adds a HTTP header to the response:

040 response header

How to configure/use

Classpath

Update your classpath by adding this dependency in your dom project’s pom.xml:

<dependency>
    <groupId>org.isisaddons.module.servletapi</groupId>
    <artifactId>isis-module-servletapi-dom</artifactId>
    <version>1.15.1.1</version>
</dependency>

Check for later releases by searching Maven Central Repo.

For instructions on how to use the latest -SNAPSHOT, see the contributors guide.

Bootstrapping

In the AppManifest, update its getModules() method, eg:

@Override
public List<Class<?>> getModules() {
    return Arrays.asList(
            ...
            org.isisaddons.module.servletapi.ServletApiModule.class,
            ...
    );
}

API & Implementation

The ServletContextProvider defines the following API:

public class ServletContextProvider {
    public ServletContext getServletContext() { ... }
}

The HttpServletRequestProvider defines the following API:

public class HttpServletRequestProvider {
    public HttpServletRequest getHttpServletRequest() { ... }
}

And finally the HttpServletResponseProvider defines the following API:

public class HttpServletResponseProvider {
    public HttpServletResponse getHttpServletResponse() { ... }
}

These actions are all programmatic and do not appear in the UI.

Known issues

None known at this time.

Dependencies

Maven can report modules dependencies using:

mvn dependency:list -o -pl modules/lib/servletapi/impl -D excludeTransitive=true

which, excluding Apache Isis itself, returns these compile/runtime dependencies:

org.apache.geronimo.specs:geronimo-servlet_3.0_spec:jar:1.0
org.apache.wicket:wicket-core:jar:7.8.0

The direct Wicket dependency is because the module implementation depends on Apache Isis, and in particular on Apache Isis' Wicket viewer. This means that it cannot be used within domain objects invoked from the REST API (Restful Objects viewer).

For further details on 3rd-party dependencies, see: