tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: JNDI - What resources are loaded?
Date Fri, 28 Jun 2002 20:04:48 GMT
There is code very similar to this in the JNDI example of the standard
"examples" webapp that comes with Tomcat 4.

Craig


On Fri, 28 Jun 2002, August Detlefsen wrote:

> Date: Fri, 28 Jun 2002 12:52:49 -0700 (PDT)
> From: August Detlefsen <augustd123@yahoo.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>,
>      augustd@codemagi.com
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: Re: JNDI - What resources are loaded?
>
> 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>
>
>


--
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