directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Directory SandBox > Embedding ApacheDS as a Web Application
Date Thu, 28 Jan 2010 13:07:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/5/_/styles/combined.css?spaceKey=DIRxSBOX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><s>Embedding ApacheDS as a Web Application</s></h2>
     <h4>Page <b>removed</b> by             <a href="http://cwiki.apache.org/confluence/display/~elecharny">Emmanuel
Lécharny</a>
    </h4>
     <br/>
     <div class="notificationGreySide">
         <h1><a name="EmbeddingApacheDSasaWebApplication-EmbeddingApacheDSasaWebApplication"></a>Embedding
ApacheDS as a Web Application</h1>

<p>My initial aim was to demonstrate embedding ApacheDS in a very simple, but nevertheless
impressive way. I thought about embedding the server in Apache Tomcat first. But then I got
a better plan: Creating a standard web application which wraps ApacheDS and can be deployed
on any compliant application server. ApacheDS in a war-archive&#33;</p>
<div>
<ul>
    <li><a href='#EmbeddingApacheDSasaWebApplication-SolutionOutline'>Solution
Outline</a></li>
    <li><a href='#EmbeddingApacheDSasaWebApplication-Step1%3AThewebcomponentwhichstartsandstopstheserver'>Step
1: The web component which starts and stops the server</a></li>
    <li><a href='#EmbeddingApacheDSasaWebApplication-PackagingandDeployingtheWebApp'>Packaging
and Deploying the WebApp</a></li>
    <li><a href='#EmbeddingApacheDSasaWebApplication-Step2%3AAddingfunctionality%3AAservletwhichdisplaystheRootDSE'>Step
2: Adding functionality: A servlet which displays the Root DSE</a></li>
    <li><a href='#EmbeddingApacheDSasaWebApplication-Downloadthesourcecode'>Download
the source code</a></li>
</ul></div>

<h2><a name="EmbeddingApacheDSasaWebApplication-SolutionOutline"></a>Solution
Outline</h2>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Proof of concept character</b><br
/><p>Although it works well, please note that this is just an example on how to embed
ApacheDS in an application&#33; If you plan to run the server as LDAP production system,
this is not the first option to consider. Some more steps have to be done, especially in the
area of configuration.</p></td></tr></table></div>
<p>The solution is quite simple. A web application carries all the necessary jar files
for ApacheDS within the lib-directory of the WEB-INF folder. When the web application is started
by the servlet container, appropriate code has to be executed to start ApacheDS. And the server
has to be stopped, if the web application goes down (for instance if the server shuts down).
There are (at least) two standard compliant ways to acomplish this:</p>
<ul>
	<li>A Servlet (automatically started with the web application, using the lifecycle
methods <em>init</em> and <em>destroy</em>)</li>
	<li>A ServletContextListener</li>
</ul>


<p>In the following we have choosen the second option.</p>

<h3><a name="EmbeddingApacheDSasaWebApplication-AServletContextListenertostartandstopApacheDS"></a>A
Servlet Context Listener to start and stop ApacheDS</h3>

<p>A servler context listener receives notifications about changes to the servlet context
of the web application it is part of. Documentation of the ServletContextListener interface
can be found <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html"
title="javadoc of javax.servlet.ServletContextListener" rel="nofollow">here</a>.
To receive notification events, the implementation class must be configured in the deployment
descriptor for the web application. The two life cycle methods <em>contextInitialized</em>
and <em>contextDestroyed</em> are suitable to start and stop ApacheDS.</p>

<h3><a name="EmbeddingApacheDSasaWebApplication-Aclientwithin"></a>A client
within</h3>

<p>After the server has been started from the Listener, it will be accessible from the
outside via the network using LDAP.  In order to demonstrate how to interact with the server
from within the VM, a simple servlet is demonstrated. It allows you to communicate with the
embedded server via web browser. This is so simple, because the server already lives within
a web application, only a servlet has to added to act as an entry point. Our sample servlet
will diplay the Root DSE of the server.</p>

<p>The following class diagram visualizes the complete example. <em>EnvHelper</em>
is a simple helper class which will be used both by the listener and the servlet.</p>

<p><img src="/confluence/download/attachments/46134/CdApacheDSinAWebApp.png" align="absmiddle"
border="0" /></p>

<h2><a name="EmbeddingApacheDSasaWebApplication-Step1%3AThewebcomponentwhichstartsandstopstheserver"></a>Step
1: The web component which starts and stops the server</h2>

<p>The ApacheDS core is a JNDI provider that manages a local hierarchical store of Attributes
objects, based on the LDAP namespace. JNDI is the access API used to hide internals, and it
is also used to configure the core.</p>

<h3><a name="EmbeddingApacheDSasaWebApplication-Ahelperclassforconfiguration"></a>A
helper class for configuration</h3>

<p>In order to keep the source code of this example simple, the following <span class="error">&#91;class|^EnvHelper.java|Download
EnvHelper.java&#93;</span> is used to provide the environment to the other classes.
Standard JNDI keys are used to tell JNDI what the provider is etc.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>EnvHelper.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> org.apache.directory.samples.embed.webapp;

<span class="code-keyword">import</span> java.util.Hashtable;
<span class="code-keyword">import</span> java.util.Properties;

<span class="code-keyword">import</span> javax.naming.Context;

<span class="code-keyword">public</span> class EnvHelper {

    <span class="code-keyword">public</span> <span class="code-keyword">static</span>
Hashtable createEnv() {
        Hashtable env = <span class="code-keyword">new</span> Properties();

        env.put(Context.PROVIDER_URL, "");
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                <span class="code-quote">"org.apache.directory.server.jndi.ServerContextFactory"</span>);

        env.put(Context.SECURITY_PRINCIPAL, <span class="code-quote">"uid=admin,ou=system"</span>);
        env.put(Context.SECURITY_CREDENTIALS, <span class="code-quote">"secret"</span>);
        env.put(Context.SECURITY_AUTHENTICATION, <span class="code-quote">"simple"</span>);

        <span class="code-keyword">return</span> env;
    }
}
</pre>
</div></div>

<h3><a name="EmbeddingApacheDSasaWebApplication-Thelistenerclass"></a>The
listener class</h3>

<p>The class <span class="error">&#91;StartStopListener|^StartStopListener.java|Download
StartStopListener.java&#93;</span> implements <em>ServletContextListener</em>
and therefore contains the following two life cycle methods:</p>
<ul>
	<li><em>contextInitialized()</em> is executed if the web application is
started by the servlet container, it starts ApacheDS embedded</li>
	<li><em>contextDestroyed()</em> is executed if the web application is stopped
by the servlet container, it stops the embedded server</li>
</ul>


<p>First of all <em>contextInitialized</em> determines an appropriate working
directory for the server. This directory is need to persist the partition data (entries).
Our example uses a simple yet portable way for this task: the context attribute <em>javax.servlet.context.tempdir</em>.<br/>
Afterwards the method creates a configuration object which is suitable to start the server
(class <em>MutableServerStartupConfiguration</em>). LDAP networking is enabled
on port 10389, and the working directory is set. The configuration is combined with the environment
from the helper class above. Invoking the constructor of InitialDirContext with these settings
causes the ApacheDS core to start.</p>

<p>The method <em>contextDestroyed</em> is comparable. It uses a configuration
suitable to shut down the server.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>StartStopListener.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> org.apache.directory.samples.embed.webapp;

<span class="code-keyword">import</span> java.io.File;
<span class="code-keyword">import</span> java.util.Hashtable;

<span class="code-keyword">import</span> javax.naming.NamingException;
<span class="code-keyword">import</span> javax.naming.directory.InitialDirContext;
<span class="code-keyword">import</span> javax.servlet.ServletContext;
<span class="code-keyword">import</span> javax.servlet.ServletContextEvent;
<span class="code-keyword">import</span> javax.servlet.ServletContextListener;

<span class="code-keyword">import</span> org.apache.directory.server.configuration.MutableServerStartupConfiguration;
<span class="code-keyword">import</span> org.apache.directory.server.core.configuration.ShutdownConfiguration;

/**
 * A Servlet context listener to start and stop ApacheDS.
 */
<span class="code-keyword">public</span> class StartStopListener <span class="code-keyword">implements</span>
ServletContextListener {

    /**
     * Startup ApacheDS embedded.
     */
    <span class="code-keyword">public</span> void contextInitialized(ServletContextEvent
evt) {

        <span class="code-comment">// Determine an appropriate working directory
</span>        ServletContext servletContext = evt.getServletContext();
        File workingDir = (File) servletContext
                .getAttribute(<span class="code-quote">"javax.servlet.context.tempdir"</span>);

        <span class="code-keyword">try</span> {
            MutableServerStartupConfiguration cfg = <span class="code-keyword">new</span>
MutableServerStartupConfiguration();
            cfg.setWorkingDirectory(workingDir);

            <span class="code-comment">// Setup LDAP networking
</span>            cfg.setEnableNetworking(<span class="code-keyword">true</span>);
            cfg.setLdapPort(10389);
            cfg.setAllowAnonymousAccess(<span class="code-keyword">false</span>);
            cfg.setAccessControlEnabled(<span class="code-keyword">false</span>);

            <span class="code-comment">// Start the Server
</span>            Hashtable env = EnvHelper.createEnv();
            env.putAll(cfg.toJndiEnvironment());
            <span class="code-keyword">new</span> InitialDirContext(env);

        } <span class="code-keyword">catch</span> (Exception e) {
            <span class="code-keyword">throw</span> <span class="code-keyword">new</span>
RuntimeException(e);
        }
    }

    /**
     * Shutdown ApacheDS embedded.
     */
    <span class="code-keyword">public</span> void contextDestroyed(ServletContextEvent
evt) {
        <span class="code-keyword">try</span> {
            Hashtable env = EnvHelper.createEnv();
            ShutdownConfiguration cfg = <span class="code-keyword">new</span>
ShutdownConfiguration();
            env.putAll(cfg.toJndiEnvironment());
            <span class="code-keyword">new</span> InitialDirContext(env);
        } <span class="code-keyword">catch</span> (NamingException e) {
            <span class="code-keyword">throw</span> <span class="code-keyword">new</span>
RuntimeException(e);
        }
    }
}
</pre>
</div></div>

<h3><a name="EmbeddingApacheDSasaWebApplication-Deploymentdescriptor"></a>Deployment
descriptor</h3>

<p>In order to execute the listener code, the class has to be defined in the deployment
descriptor of a web application, as depicted below:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;!DOCTYPE web-app PUBLIC <span class="code-quote">"-//Sun Microsystems, Inc.//DTD
Web Application 2.3//EN"</span>
<span class="code-quote">"http://java.sun.com/dtd/web-app_2_3.dtd"</span>&gt;
<span class="code-tag">&lt;web-app&gt;</span>
  <span class="code-tag">&lt;display-name&gt;</span>ApacheDS embedded
in a WebApp<span class="code-tag">&lt;/display-name&gt;</span>
  <span class="code-tag">&lt;description&gt;</span>
    A simple yet portable way to run ApacheDS within a servlet
    container
  <span class="code-tag">&lt;/description&gt;</span>

  <span class="code-tag">&lt;listener&gt;</span>
    <span class="code-tag">&lt;listener-class&gt;</span>
      org.apache.directory.samples.embed.webapp.StartStopListener
    <span class="code-tag">&lt;/listener-class&gt;</span>
  <span class="code-tag">&lt;/listener&gt;</span>
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div>

<h2><a name="EmbeddingApacheDSasaWebApplication-PackagingandDeployingtheWebApp"></a>Packaging
and Deploying the WebApp</h2>

<p>A standard web archive (war-File) is needed in order to deploy the application to
a servlet container. The Resources area at the end of this page provides a zip-File which
contains the file structure. A build script for <a href="http://ant.apache.org" title="ant.apache.org"
rel="nofollow">Apache Ant</a> is included as well.</p>

<h3><a name="EmbeddingApacheDSasaWebApplication-Directorylayoutforthesources%2Cwarfilelayout"></a>Directory
layout for the sources, war file layout</h3>

<p>The build script assumes that you have ApacheDS 1.0.1 and Tomcat 5.5.20 installed
locally; it uses and (in the case of ApacheDS) copies the necessary your file from their <em>lib</em>
directories to the <em>lib</em> directory of the web application. You will likely
want to adjust the installation directories defined in the build.xml file.</p>

<p><img src="/confluence/download/attachments/46134/directoryLayout.png" align="absmiddle"
border="0" /></p>

<p>After building the project, the <em>classes</em> folder will contain
the compiled class files of the three Java classes above, and a properties file to configure
the logging framework log4j. The <em>lib</em> folder will contain all jar-Files
necessary, these are</p>

<ul>
	<li>antlr-2.7.6.jar</li>
	<li>apacheds-core-1.0.1.jar</li>
	<li>apacheds-core-shared-1.0.1.jar</li>
	<li>apacheds-kerberos-shared-1.0.1.jar</li>
	<li>apacheds-protocol-changepw-1.0.1.jar</li>
	<li>apacheds-protocol-kerberos-1.0.1.jar</li>
	<li>apacheds-protocol-ldap-1.0.1.jar</li>
	<li>apacheds-protocol-shared-1.0.1.jar</li>
	<li>apacheds-server-jndi-1.0.1.jar</li>
	<li>backport-util-concurrent-2.2.jar</li>
	<li>commons-cli-1.0.jar</li>
	<li>commons-collections-3.2.jar</li>
	<li>commons-lang-2.1.jar</li>
	<li>jdbm-1.0.jar</li>
	<li>logger.jar</li>
	<li>mina-core-1.0.2.jar</li>
	<li>mina-filter-ssl-1.0.2.jar</li>
	<li>shared-asn1-0.9.5.4.jar</li>
	<li>shared-asn1-codec-0.9.5.4.jar</li>
	<li>shared-ldap-0.9.5.4.jar</li>
</ul>


<p>The <em>webapp</em> target in the <em>build.xml</em> file
(which is the default target) packs the files for the web application together in a web archive
called <em>ApacheDS.war</em>.</p>

<h3><a name="EmbeddingApacheDSasaWebApplication-DeployingonApacheTomcat"></a>Deploying
on Apache Tomcat</h3>

<p>In order to run the application within Tomcat, simply put the <em>ApacheDS.war</em>
file in the <em>webapps</em> directory of your Tomcat installation and start the
server. If you have the manager application enabled (as described <a href="http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html"
title="tomcat.apache.org" rel="nofollow">here</a>), you can see and "manage" (start/stop)
ApacheDS within its list view.</p>

<p><img src="/confluence/download/attachments/46134/tomcatManager.png" align="absmiddle"
border="0" /></p>

<h3><a name="EmbeddingApacheDSasaWebApplication-ConnectingtoApacheDSfromtheoutside"></a>Connecting
to ApacheDS from the outside</h3>

<p>ApacheDS is up and running within the servlet container. Besides the administration
tool listing, it seems to be invisible. But because we have configured network access via
port 10389, you can easily access the server with an arbitrary LDAP client from outside.</p>

<p>One option is a command line tool like <em>ldapsearch</em> (see <a
href="http://directory.apache.org/apacheds/1.0/apacheds-v10-basic-users-guide.html" title="ApacheDS
Basic User's Guide" rel="nofollow">ApacheDS Basic User's Guide</a> for details on
how to connect to ApacheDS with such tools in general). Here is an example how to connect
as administrator (simple bind) and fetch the Root DSE of our embedded ApacheDS instance:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-none">
$ ldapsearch -h localhost -p 10389 -D "uid=admin,ou=system" -w secret \\
    -b "" -s base "(objectClass=*)" * +
version: 1
dn:
supportedLDAPVersion: 3
ObjectClass: extensibleObject
ObjectClass: top
subschemaSubentry: cn=schema,ou=system
supportedFeatures: 1.3.6.1.4.1.4203.1.5.1
vendorName: Apache Software Foundation
supportedExtension: 1.3.6.1.4.1.1466.20036
namingContexts: ou=system
supportedControl: 2.16.840.1.113730.3.4.3
supportedControl: 2.16.840.1.113730.3.4.7
supportedControl: 1.3.6.1.4.1.4203.1.10.1
supportedControl: 2.16.840.1.113730.3.4.2
vendorVersion: 1.0.1
$
</pre>
</div></div>
<p>Another choice are graphical LDAP clients like JXplorer or Softerra LDAP Browser
(see <a href="http://directory.apache.org/apacheds/1.0/apacheds-v10-basic-users-guide.html"
title="ApacheDS Basic User's Guide" rel="nofollow">ApacheDS Basic User's Guide</a>
for details on how to connect to ApacheDS with such tools in general).</p>

<p>With the Eclipse RCP application <a href="http://directory.apache.org/ldapstudio/"
title="directory.apache.org" rel="nofollow">LDAP studio</a>, connecting goes like
this:<br/>
In the Connections view, select "New connection ...". Within a wizard dialog, you provide
the connection data (host name, port, bind DN and password).</p>

<p><img src="/confluence/download/attachments/46134/LDAPStudio1.png" align="absmiddle"
border="0" /></p>

<p><img src="/confluence/download/attachments/46134/LDAPStudio2.png" align="absmiddle"
border="0" /></p>

<p>After successfully connecting to the embedded ApacheDS, you can browse the tree,
add and manipulate entries and so on. If you check the connection properties, you can study
the Root DSE as well.</p>

<p><img src="/confluence/download/attachments/46134/LDAPStudio3.png" align="absmiddle"
border="0" /></p>

<h3><a name="EmbeddingApacheDSasaWebApplication-OtherWebApplicationServers"></a>Other
Web Application Servers</h3>

<p>The web application described here has been successfully deployed on</p>
<ul>
	<li>Apache Tomcat 5.5.20 and 6.0.9-beta (<a href="http://tomcat.apache.org" title="tomcat.apache.org"
rel="nofollow">Homepage</a>)</li>
	<li>IBM WebSphere Application Server 6.1 (<a href="http://www.ibm.com/software/webservers/appserv/was/"
title="www.ibm.com" rel="nofollow">Homepage</a>)</li>
	<li>Jetty 6.1.0 (<a href="http://http://jetty.mortbay.org" title="jetty.mortbay.org"
rel="nofollow">Homepage</a>)</li>
</ul>


<p>Here is a screen shot of the web based administration console of WebSphere Application
Server 6 with the ApacheDS.war deployed and running, no changes in the deployment archive
were needed. <br/>
<img src="/confluence/download/attachments/46134/webSphereConsole.png" align="absmiddle"
border="0" /></p>

<h2><a name="EmbeddingApacheDSasaWebApplication-Step2%3AAddingfunctionality%3AAservletwhichdisplaystheRootDSE"></a>Step
2: Adding functionality: A servlet which displays the Root DSE</h2>

<p>To finish with, here is a simple example on how to access the server internally.</p>

<p>The following servlet, which will be deployed together with the other two classes
in the web archive, connects to ApacheDS directly, i.e. via the internal JNDI provider. No
network access is needed.  In the <em>doGet</em> method it performs a search operation
against the Root DSE of the server, as the examples above do. </p>


<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>RootDseServlet.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> org.apache.directory.samples.embed.webapp;

<span class="code-keyword">import</span> java.io.IOException;
<span class="code-keyword">import</span> java.io.PrintWriter;

<span class="code-keyword">import</span> javax.naming.NamingEnumeration;
<span class="code-keyword">import</span> javax.naming.directory.Attribute;
<span class="code-keyword">import</span> javax.naming.directory.Attributes;
<span class="code-keyword">import</span> javax.naming.directory.DirContext;
<span class="code-keyword">import</span> javax.naming.directory.InitialDirContext;
<span class="code-keyword">import</span> javax.naming.directory.SearchControls;
<span class="code-keyword">import</span> javax.naming.directory.SearchResult;
<span class="code-keyword">import</span> javax.servlet.ServletException;
<span class="code-keyword">import</span> javax.servlet.http.HttpServlet;
<span class="code-keyword">import</span> javax.servlet.http.HttpServletRequest;
<span class="code-keyword">import</span> javax.servlet.http.HttpServletResponse;

<span class="code-keyword">public</span> class RootDseServlet <span class="code-keyword">extends</span>
HttpServlet {

    <span class="code-keyword">protected</span> void doGet(HttpServletRequest
req, HttpServletResponse resp)
            <span class="code-keyword">throws</span> ServletException, IOException
{

        <span class="code-keyword">try</span> {
            resp.setContentType(<span class="code-quote">"text/plain"</span>);
            PrintWriter out = resp.getWriter();

            out.println(<span class="code-quote">"*** ApacheDS RootDSE ***\n"</span>);

            DirContext ctx = <span class="code-keyword">new</span> InitialDirContext(EnvHelper.createEnv());

            SearchControls ctls = <span class="code-keyword">new</span> SearchControls();
            ctls.setReturningAttributes(<span class="code-keyword">new</span>
<span class="code-object">String</span>[] { <span class="code-quote">"*"</span>,
<span class="code-quote">"+"</span> });
            ctls.setSearchScope(SearchControls.OBJECT_SCOPE);

            NamingEnumeration result = ctx.search(<span class="code-quote">"", "</span>(objectClass=*)",
ctls);
            <span class="code-keyword">if</span> (result.hasMore()) {
                SearchResult entry = (SearchResult) result.next();
                Attributes as = entry.getAttributes();

                NamingEnumeration ids = as.getIDs();
                <span class="code-keyword">while</span> (ids.hasMore()) {
                    <span class="code-object">String</span> id = (<span class="code-object">String</span>)
ids.next();
                    Attribute attr = as.get(id);
                    <span class="code-keyword">for</span> (<span class="code-object">int</span>
i = 0; i &lt; attr.size(); ++i) {
                        out.println(id + <span class="code-quote">": "</span>
+ attr.get(i));
                    }
                }
            }
            ctx.close();

            out.flush();
        } <span class="code-keyword">catch</span> (Exception e) {
            <span class="code-keyword">throw</span> <span class="code-keyword">new</span>
ServletException(e);
        }
    }
}
</pre>
</div></div>

<p>In order to make the servlet available to clients, it has to be declared in the deployment
descriptor <em>web.xml</em>, here are the additions (a servlet named <em>RootDseServlet</em>
for the class above, and a URL mapping)</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>web.xml, extended</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;!DOCTYPE web-app PUBLIC <span class="code-quote">"-//Sun Microsystems, Inc.//DTD
Web Application 2.3//EN"</span>
<span class="code-quote">"http://java.sun.com/dtd/web-app_2_3.dtd"</span>&gt;
<span class="code-tag">&lt;web-app&gt;</span>

  ...
  <span class="code-tag">&lt;servlet&gt;</span>
    <span class="code-tag">&lt;servlet-name&gt;</span>RootDseServlet<span
class="code-tag">&lt;/servlet-name&gt;</span>
    <span class="code-tag">&lt;servlet-class&gt;</span>
      org.apache.directory.samples.embed.webapp.RootDseServlet
    <span class="code-tag">&lt;/servlet-class&gt;</span>
  <span class="code-tag">&lt;/servlet&gt;</span>

   <span class="code-tag">&lt;servlet-mapping&gt;</span>
     <span class="code-tag">&lt;servlet-name&gt;</span>RootDseServlet<span
class="code-tag">&lt;/servlet-name&gt;</span>
     <span class="code-tag">&lt;url-pattern&gt;</span>/RootDse<span
class="code-tag">&lt;/url-pattern&gt;</span>
   <span class="code-tag">&lt;/servlet-mapping&gt;</span>
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div>

<p>Redeploy the web application. If you point to your tomcat server with the appropriate
URL (<a href="http://localhost:8080/ApacheDS/RootDseServlet" rel="nofollow">http://localhost:8080/ApacheDS/RootDseServlet</a>),
you'll the the content of the Root DSE as depicted below: </p>

<p><img src="/confluence/download/attachments/46134/RootDseServlet.png" align="absmiddle"
border="0" /></p>

<h2><a name="EmbeddingApacheDSasaWebApplication-Downloadthesourcecode"></a>Download
the source code</h2>

<p><img src="/confluence/download/attachments/46134/page_white.png" align="absmiddle"
border="0" /> <span class="error">&#91;EnvHelper.java|^EnvHelper.java|Download
file EnvHelper.java&#93;</span><br/>
<img src="/confluence/download/attachments/46134/page_white.png" align="absmiddle" border="0"
/> <span class="error">&#91;StartStopListener.java|^StartStopListener.java|Download
file StartStopListener.java&#93;</span><br/>
<img src="/confluence/download/attachments/46134/page_white.png" align="absmiddle" border="0"
/> <span class="error">&#91;RootDseServlet.java|^RootDseServlet.java|Download
file RootDseServlet.java&#93;</span><br/>
<img src="/confluence/download/attachments/46134/page_white_code.png" align="absmiddle"
border="0" /> <span class="error">&#91;web.xml|^web.xml|Download file web.xml&#93;</span><br/>
<img src="/confluence/download/attachments/46134/page_white.png" align="absmiddle" border="0"
/> <span class="error">&#91;ApacheDSWebApp.zip|^ApacheDSWebApp.zip|Download file
ApacheDSWebApp.zip&#93;</span> all sources incl. Ant build.xml</p>


     </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message