tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From August Detlefsen <augustd...@yahoo.com>
Subject Re: JNDI - What resources are loaded?
Date Fri, 28 Jun 2002 19:52:49 GMT
Thanks Nikola !

I was intrigued by this, so I took it a step further and made it
recursive -it now lists all bindings with one click. I hope this is
useful to someone: 

<%@ page
    import="javax.naming.*"
%>

<HTML>
<HEAD>
<TITLE>JNDI Bindings</TITLE>
</HEAD>
<BODY>

<%
        Context initCtx = new InitialContext();

        String initContextName = "java:";

        displayContext(initContextName, "", out, initCtx);
%>

</BODY>

<%!

        private void displayContext(String contName, String
prevContName, javax.servlet.jsp.JspWriter out, Context ctx) 
                throws javax.naming.NamingException,
java.io.IOException {

                String fieldSep = "/";
                if (prevContName == null || "".equals(prevContName) ||
prevContName.endsWith(":") ) {
                        fieldSep = "";
                }

                String lookupCtx = prevContName + fieldSep + contName;

                NamingEnumeration names = ctx.listBindings(lookupCtx);

                out.print("<UL>");

                while ( names.hasMore() ) {

                        Binding bind = (Binding)names.next();

                        out.print( "<LI><B>" + bind.getName() + "</B> =
" + bind.getObject().toString() );

                        if (bind.getObject() instanceof
javax.naming.Context) {
                                displayContext(bind.getName(),
lookupCtx, out, ctx);
                        }
                }

                out.print("</UL>");

        }
%>



--- Nikola Milutinovic <Nikola.Milutinovic@ev.co.yu> wrote:
> > Is there a way to list all of the JNDI Resources that are loaded
> for a
> > particular context? 
> 
> Sure.
> 
> Here is a snipp from my "JNDI browser" JSP:


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message