Hi,
A simple (but not very smart) way to do this is to setup a setContext (or
any other name) method in you bean that takes a context as parameter and
store a reference to it. You can then call this method from a scriplet in
your JSP and pass it the current context. Only after this will you be able
to use the context in the bean.
An other way is to define your own replacement of the useBean Tag that will
initialize the bean, passing it a reference to the context. For this, you
will have to make you bean implement an interface that declares the
setContext method (or whatever you call it).
In any case, you should think about why you need a reference to the context
in your bean. Depending on what you want to do, there may be safer
solutions, like passing only references to the data you really need from the
context, instead of a reference to the context itself. (Typical need could
be the root document path. If that is your case, it's much safer to pass a
reference to a String holding this info than to the context itself.)
Pierre-Yves
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
Shivashankar Krishnan
Envoy� : samedi 15 septembre 2001 12:49
� : [EMAIL PROTECTED]
Objet : contact Servletcontext from bean
Is it possible to access the Servletcontext from a
session bean or access the servlet session from a
session bean
Regds
Shivashankar
__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html