Peter �stergren wrote:

> Hi everybody,
>
> My problem is that I want to cheare a object between some servlets and
> sessions.
>
> Normaly it shouldn't be any problem if I could use the
> ServletContext.setAttribute(...)  method too store the referens,
> but I'm stuck on an older version where that the method is't implemented
> yet.
>
> Is there anyone who can help me or give me an hint on this problem.
>
> //Peter
> [...]

Hi :-)  I am not sure, I think one of the ways is: (I suppose the class-name
of that object is MyUtility)

* make MyUtility with SingleTon pattern
* make sure that MyUtility is loaded by:
  - System classloader(for ex., put it in CLASSPATH)
  - ext classloader(for ex., put it in JAVA_HOME/jre/lib/ext
* then, normally, when you want to use that object, you can use
   the following code:
   MyUtility myu=MyUtility.getInstance();

I think you can use the above code in:
- diferent Servlet in the same ServletContext
- diferent ServletContext
- diferent instance of Servlet container which run in the same JVM(?)

perhaps the above needs the following:
- that container doesn't disable CLASSPATH
- that container uses "Java2 delegate modol"


Bo
July 20, 2001

___________________________________________________________________________
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

Reply via email to