This project has retired. For details please refer to its Attic page.
Servlet
Qi4j
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

Servlet

code

docs

tests

This library provide the necessary boilerplate code to bootstrap a Qi4j Application in a Servlet container plus some facilities. It aims at a very simple need and is provided as an example integration.

If instead you want to run a servlet container inside a Qi4j Application, see HTTP Library.

Table 48. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.servlet

2.0


Application Bootstrap

Extends AbstractQi4jServletBootstrap to easily bind a Qi4j Application activation/passivation to your webapp lifecycle.

Use Qi4jServletSupport#application(javax.servlet.ServletContext) to get a handle on the Application from the ServletContext.

Here is an example ServletContextListener:

public static class FooServletContextListener
        extends AbstractQi4jServletBootstrap
{

    public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
            throws AssemblyException
    {
        ApplicationAssembly appass = applicationFactory.newApplicationAssembly();
          [...snip...]

        return appass;
    }

}

Facilities

Qi4jServlet and Qi4jFilter respectively provide base class for easy access to the Application from the ServletContext.

Here is a sample servlet that simply output the assembled Application name:

public static class FooServlet
        extends Qi4jServlet
{

    @Override
    protected void doGet( HttpServletRequest req, HttpServletResponse resp )
            throws ServletException, IOException
    {
        // Output the assembled Application's name as an example
        resp.getWriter().println( application().name() );
    }

}

Logging

The SLF4J logger used by this library is named "org.qi4j.library.servlet".