Gladly.  In the .jsps I want to record hit counts, I have:
<%@ page import = "javax.naming.*"%>
<%
 Context ctx = new InitialContext();
 long lhits = 0;
 try {
  Long LhitCount = (Long) ctx.lookup("<<domain>>/<<page>>.jsp");
  lhits = LhitCount.longValue() + 1;
  ctx.rebind("("<<domain>>/<<page>>.jsp", new Long( lhits));
 }
 catch(NameNotFoundException nnfe) {
  %> not found <%
  lhits = 1;
  ctx.bind("("<<domain>>/<<page>>..jsp", new Long(lhits));
 }
%>
By domain context, I mean the root context for the domain (or web
application).  While you may be right about Bindings being read only (and
what I'm doing is actually removing an old binding and creating a new one),
the result is, in effect, a writable environment variable that I can see
from a client.
Note that I do this 'inside' the domain (in the app servers JVM, not the
client's.)  I haven't tried it from the client.

----- Original Message -----
From: "Tim Endres" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Cc: "Reid Hartenbower" <[EMAIL PROTECTED]>
Sent: Saturday, January 06, 2001 3:17 PM
Subject: Re: Globally available environment vars


> Could you please elaborate on this? What do you mean when you say "domain
context"?
> Also, I was under the impression that these values were read-only, not
writable.
> What am I missing?
> tim.
>
> > Yes.  I use domain contexts just like you describe to store page hit
counts,
> > so I can see traffic from a remote client.
> >
> > ----- Original Message -----
> > From: "Tim Endres" <[EMAIL PROTECTED]>
> > To: "Orion-Interest" <[EMAIL PROTECTED]>
> > Sent: Friday, January 05, 2001 3:23 PM
> > Subject: RE: Globally available environment vars
> >
> > > Are you sure? Seems to me that all you have to do is use the
constructor
> > > InitialContext( Properties props ) to specify the environment that you
wish
> > > via the java.naming.provider.url property. In other words, can't a web
module
> > > just use "ormi://host:port/appname" to get a Context that can access
the
> > > environment of the ejb module "appname"?
> > >
> > > > well, the problem is that there seems not to be a context which is
> > > > accessable from all the modules! It looks like this may be a J2EE
deficiency
> > > > .. I'm just gonna use a properties file ..
> > > >
> > > > jd
> > > >
> > > > > -----Original Message-----
> > > > > From: [EMAIL PROTECTED]
> > > > > [mailto:[EMAIL PROTECTED]]On Behalf Of Jason
Smith
> > > > > Sent: Friday, January 05, 2001 1:19 PM
> > > > > To: Orion-Interest
> > > > > Subject: RE: Globally available environment vars
> > > > >
> > > > >
> > > > > How about having an initializer bind some property files into
> > > > > JNDI that can
> > > > > then be accessed by the web & ejb modules.
>
>



Reply via email to