chris brown wrote:
>
> I like the idea of using JNDI for this.  Nevertheless, I've a couple of
> questions about this approach:
>
> 1./
> How can I get the correct initial context without hard coding JNDI setup
> info into the webapp somewhere?  The appropriate JNDI data source is most
> likely to vary according to the deployment environment.  Isn't it a bit like
> saying "load the information from a properties file", as you still need to
> indicate where this is, and without being able to modify the deployment
> properties, you're still stuck with hard-coding this info?

A web container that supports this feature is also responsible for
providing the correct initial context (and making the resources available
according to the naming conventions defined by the Servlet spec),
so you use "new InitialContext()".

> 2./
> What sort of entry level JNDI data sources could I use for this?  I'm not
> really familiar with low-cost simple solutions across platforms.  I imagine
> I could use OpenLDAP with Linux, and perhaps Active Directory if deploying
> under Win2000 or later, or even Weblogic's or Websphere's server, but these
> Windows solutions are not always available.

Again, the container provide the JNDI implementation. AFAIK, the latest
Tomcat 4.0 Beta supports access to application resources through JNDI.

> -Chris

Hans

> ----- Original Message -----
> From: "Hans Bergsten" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, June 08, 2001 1:41 AM
> Subject: Re: Deploying a web app as a war file then supplying init params
>
> > chris brown wrote:
> > >
> > > Hello,
> > >
> > > I'm developing a web app which I plan to deploy on several systems.  I'm
> > > trying to avoid hard-coding anything into the app, so for example
> database
> > > connections, log file paths, etc. are specified as init-params on the
> > > appropriate servlets.
> > >
> > > When I deploy this as a "war" file (web archive), I'd like it if the
> > > administrator of the system where it's being deployed can modify the
> init
> > > params WITHOUT unarchiving / decompressing the archive (especially I
> need to
> > > sign or otherwise encrypt the archive).  If not, how else can I design
> an
> > > app so that it's portable and easy to deploy?
> >
> > The idea behind the init parameters in web.xml is that the container
> > should provide deployment tools where the values can be set. Some
> > containers do, others don't. For those that don't, I don't see any way
> > to avoid unpacking the WAR file, but instead of asking the administrator
> > to edit the web.xml file, you may have your own configuration file in
> > the WEB-INF directory (e.g. a properties file or an XML file). You can
> > easily read a file from WEB-INF with context.getResourceAsStream().
> >
> > There's one other alternative, but only for containers that provide JNDI
> > support (all complete J2EE containers, but not all simple web containers).
> > For this type of container you can use the <resource-ref> and <env-entry>
> > elements in the web.xml file to declare names for all configuration items
> > you need. The deployer then configures these items in the JNDI server, and
> > the web application get access to them through JNDI calls.
> >
> > Hans
> > --
> > Hans Bergsten           [EMAIL PROTECTED]
> > Gefion Software         http://www.gefionsoftware.com
> > Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to