Arun Thomas wrote:
>
> Hans,
>
> Thanks for the mail.  My goal with this was to simply access application
> configuration
> data.  Right now, I've already done exactly what you suggest - load this
> information using
> a startup servlet, and use it from the application context.  Nevertheless,
> it seems to me
> that ideally values stored in the application context should have an
> application wide
> function, rather than a function in just one servlet/jsp.

Yes, I agree. If a parameter only applies to one servlet, servlet init
params are preferred over servlet context params. But you originally asked
about init params for a JSP page. The reason I suggested that init params
for a JSP page may not be ideal was based on the assumption that you use
JSP pages only to present some result that's been created by a servlet, or
by generic custom actions and/or beans embedded in the JSP page. With this
model, the init params are likely not tied to a specific JSP page, rather
to a servlet or the application as such.

> The servlet initialization
> parameters are quite useful in this way, allowing one to see the direct
> connection between
> changes to the servlet and its associated parameters - parameters that are
> not used elsewhere
> by other pages.  In the same way, I was hoping to initialize the JSP page.


As Craig pointed out in another reply, you *can* set init params for a JSP page
if you use a Servlet 2.2/JSP 1.1 container. In the web.xml file you can define
a name and parameters for a JSP page. But again, in most cases I believe the
init params belong to another object than the page.

> > -----Original Message-----
> > From: A mailing list about Java Server Pages specification and reference
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Hans Bergsten
> > Sent: Friday, December 17, 1999 8:00 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: FW: Initialization Parameters for JSPs
> >
> >
> > Arun Thomas wrote:
> > >
> > > Hello all,
> > >
> > > I posted this earlier, but didn't receive a copy from the list.  So I'm
> > > posting again in the hopes of some suggestions.
> > >
> > > I'm trying to find out how to setup initialization parameters for a jsp.
> > > The config implicit object exists, and is obviously meant to make it
> > > possible to access these parameters from the JSP, but how do I identify
> > > the values for these parameters in servelet.properties?  I don't really
> > > have a name to use for each particular jsp, as the actual servlet
> > > used is generated dynamically.
> >
> > Yes, the config object is there, but I'm not so sure it should be ;-)
> > Even though JSP pages are turned into servlets, I don't think it makes
> > much sense to set init params for a page. Can you tell us what type of
> > init params you have in mind?
> >
> > If you need to access application configuration data (i.e. info that
> > applies to the application as opposed to a specific page), you can use
> > servlet context (mapped to the "application" object) attributes.
> >
> > You can use a servlet that loads on startup to initialize the context
> > attributes (for instance using its init params). In Servlet 2.2/JSP 1.1
> > simple string based servlet context init params can also be defined in the
> > web.xml file.

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to