This will work.  But there is a limitation with it from an OO perspective.
I guess it depends how you do it, but if you're passing the bean objects
from the servlet container, and then using servlet API method calls on those
objects in the bean, you've made your bean useless outside of a servlet
container context, i.e., non-reusable.

Does it really matter if it gets the job done and you're never going to use
the bean for anything else?  No.  But you could just as easily do what I
suggested in an earlier email, which is get the ServletConfig object in a
JSP or servlet, call its methods to retrieve parameters, and then use the
returned strings to set the bean's properties.  That way the bean is at
least _potentially_ reusable in a servlet application context, or otherwise
(EJB, applet, etc.).

Scott Stirling
Allaire Corporation
http://www.allaire.com/developer/jrunreferencedesk/

> -----Original Message-----
> From: Matt Goss [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 11, 2000 9:47 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Reading Context Params from web.xml
> 
> 
> 
> Gaurav,
> If you are using the bean in a servlet or JSP then you can 
> pass the ServletConfig object to
> the Bean. The init parameters can then be obtained with
> ServletConfig.getServletContext().getInitParameter("myparameter");
> I'm using this method and it works quite well.
> Matt Goss
> 
> Gaurav Gehlot wrote:
> 
> > Hi,
> >   Actually what I am trying to do here is that I want to 
> set the application
> > init parameters thru the JMC and then read them in my bean 
> class.This bean
> > class doesnt have any ServletContext or ServletConfigObject 
> availbale to
> > it.So I cant use the normal 
> ServletContext.getInitParameter() method.
> > So I was thinking that if there is any other way provided by JRun to
> > programatically read the web.xml file.
> >
> > gg
------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the 
body.

Reply via email to