Hi Robert,

Congratulations on having Embedded Tomcat in your application.

My apologies for not explaining a solution to your problem more clearly.

The method we had discussed by private mail earlier today indeed works. I
cannot give you actual source code, simply because I'm downloading Tomcat at
the moment.

The only part that you need to work on is the :
> MyApplication app = <someway of getting access to the instantiated object>;

that you have mentioned below:

Let's say your application (with all its parts) is represented by
MyApplication.

You could create the class along the lines of :

public class MyApplication{

private static MyApplication currentInstance = null;

private MyApplication(){
}

public MyApplication getCurrentInstance(){
    if (currentInstance==null){
        currentInstance = new MyApplication();
        initialize();  // some initialization work
    }
    return currentInstance;
}

}

You should now be able to access MyApplication's object from within your web
applications via MyApplication.getCurrentInstance();

In your care, you do not need JNDI. There is another means of sharing objects
(via JMX) that I shall explore once this Tomcat download is completed.

-- Sriram

--- Robert Charbonneau <[EMAIL PROTECTED]> wrote:
> I've successfully embedded Tomcat into my application and have talked to a
> few 
> people about how to shared objects between the application and the JSPs from 
> the contexts I've defined.  I've had a suggested to use JNDI but this seems a
> 
> little more elaborate than I need, and someone else was talking about using 
> ServletContext.setAttribute() and ServletContext.getAttribute()
> 
> Is there a code example both application side and web side somewhere that 
> could show me how to do this?  I've been wrestling with this for a while and 
> it's starting to irritate me.  :)
> 
> I've embedded Tomcat for the sole purpose of being able to create JSPs and 
> Servlets that can examine the properties of the application and modify the 
> properties as well.  For example, I need to be able to do the following in my
> 
> JSP.
> 
> MyApplication app = <someway of getting access to the instantiated object>;
> 
> Object obj = app.getSomeData();
> obj.modifyInSomeWay();
> app.setSomeData(obj);
> 
> If anyone can provide an example for this, I would very much appreciate it.
> 
> Thanks.
> 
> --
> Robert Charbonneau
> [EMAIL PROTECTED]
> --
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to