You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Torgeir Veimo <to...@vertech.no> on 2001/03/16 11:24:34 UTC

using self created Context with jndi taglib

I'm trying to use the jndi taglib with a context that comes from my own
context pool.

The code is included below. But I guess that the context needs to be
references in the PageContext in order to be found by the tag?

Is there an easy way to do this? I plan to create a tag that fetches a
context from my context pool later, but for now it would be nice to be
able to put a context into the pagecontext temporarily.


<%@page contentType="text/html" import="profile.*, javax.naming.*" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/jndi" prefix="jndi" %>
<html>
<head><title>Profile</title></head>
<body>

<h3>Profile for </h3>

<%
    ContextPool ctxPool = (ContextPool)
session.getAttribute("contextPool");
    System.out.println("context pool retrieved: " + ctxPool);

    System.out.println("using dn: " +
request.getSession().getAttribute("username") 
        + ", credentials: " + 
request.getSession().getAttribute("credentials"));

    Context testCtx =
ctxPool.getContext((String)request.getSession().getAttribute("username"), 
        (String)request.getSession().getAttribute("credentials"));

    System.out.println("context retrieved: " + testCtx);
        
%>

<jndi:lookup contextRef='testCtx' name='uid=test, ou=people,
o=ecomda.de' id="hmm" /> 

<!-- doesn't work. the testCtx is not found. The exception is included
below -->

 
</body>
</html>


javax.servlet.jsp.JspException: context not set in a lookup invocation
<...>

-- 
- Torgeir