Hi, Ross.

     This sort of defeats the purpose of beans.  You should develop your beans
without any dependencies whatsoever on servlet-specific stuff, like requests
or sessions.  This way, your model is independent of the "web" environment and
could be used in some other context.  Your servlet should get the request and
handle it and also figure out any init parameters.  Then, just pass the bean
whatever it needs.

HTH,
-Jeff



                                                                                       
                             
                    Fullerton Ross                                                     
                             
                    S                     To:     "'[EMAIL PROTECTED]'"   
                             
                    <Ross.Fullerto        <[EMAIL PROTECTED]>             
                             
                    [EMAIL PROTECTED]>            cc:                                          
                             
                                          Subject:     getInitParameter from within a 
bean?                         
                    01/17/02 05:06                                                     
                             
                    AM                                                                 
                             
                    Please respond                                                     
                             
                    to "Tomcat                                                         
                             
                    Users List"                                                        
                             
                                                                                       
                             
                                                                                       
                             




I've got a Bean that I want to be able to access some of the <context-param>
entries in my web.xml on Tomcat 3.3.

>From the documentation, I access these values through

String value = getServletContext().getInitParameter("name");

I can't get this to work from within my bean, the compiler returns the
following error:

newUserBean.java:505: cannot resolve symbol
symbol  : method getServletContext  ()
location: class newUserBean
      String emailReturnAddress =
getServletContext().getInitParameter("emailReturnAddress");
                                  ^
1 error

Is there a way of accessing the context-params from within a bean rather
than a servlet?

Thanks,

Ross Fullerton

ICL                  Systems Engineer, Libra Project
Phone:          +44(0)118 377 5422
Internal:       730 35422
Mobile:         +44(0)7810 697100
Address:        Eskdale Road, Winnersh, Wokingham, Berkshire, RG41 5TT, UK.
Internet:       www.icl.com


  This e-mail is intended only for the addressee named above. As this e-mail
may contain confidential or privileged information if you are not, or
suspect that you are not, the named addressee or the person responsible for
delivering the message to the named addressee, please telephone us
immediately. Please note that we cannot guarantee that this message or any
attachment is virus free or has not been intercepted and amended. The views
of the author may not necessarily reflect those of the Company.
International Computers Limited, Registered in England no 96056, Registered
Office 26, Finsbury Square, London EC2A 1SL

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>






--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to