I was thinking about this last weekend. I did finally work through some of the examples with the JNDI taglibrary. There are examples in the usage of that jndi taglibrary that show both the resources and the env available to a webapplications under:

java:comp/...

The simplest example of navigating this hierarchy using the jndi taglib is this:

<%@ page errorPage="/Error/ErrorPage.jsp" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/jndi-1.0"; prefix="jndi" %>

<%
String name = request.getParameter("name") != null ? request.getParameter("name") : "";
String url = request.getParameter("url") != null ? request.getParameter("url") : "java:comp";
%>


<jndi:useContext id="test" url='<%=url%>'/>
The Context is <%=test.toString()%>"<BR/>

<table border="true">
<th>name</th><th>full name</th><th>class</th><th>toString of Object</th>
<jndi:list
contextRef='test'
name='<%=name%>'
nameId="aName"
classId="aClass"
objId="anObj"
bindings="false"
>
<%
String nextContext, dn;
if (anObj instanceof javax.naming.Context) {
nextContext = ((javax.naming.Context)anObj).composeName(aName, request.getParameter("name"));
dn = ((javax.naming.Context)anObj).getNameInNamespace();
%>
<tr>
<td><%=aName%><BR/>
<A href='?url=<%=url%>&name=<%=nextContext%>'>[list]</a>
<td><%=dn%></td>
<td><%=aClass%></td>
<td><%=anObj%></td>
</tr>
<% } else {
nextContext=test.composeName(aName, name);
dn = "N/A";
%>
<tr>
<td><%=aName%><BR/>
<A href='?url=<%=url%>&name=<%=nextContext%>'>[list]</a>
<td><%=dn%></td>
<td><%=aClass%></td>
<td><%=anObj%></td>
</tr>


<%}%>
  </jndi:list>
</table>


This thread in archive: http://www.mail-archive.com/[EMAIL PROTECTED]/msg05920.html


-- Mark Diggory Software Developer Harvard MIT Data Center http://osprey.hmdc.harvard.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to