Title: RE: *** Sharing beans between Servlets and JSPs ***

Hey Alex,

There may be another way to do it, probably is, but I put everything that I persist in the Session.  I use IBM's session, but javax.servlet.http.HttpSession will also do the trick.  In the Servlet the code looks like this:

req is an HttpServletRequest object.

        //Create a Session
        IBMSessionData session = (IBMSessionData) req.getSession(true);
        // create a new JSPMessage Object
        JSPMessage ArtistMessage = new JSPMessage();
        // Insert new JSPMessage Object into the request object
        session.putValue("JSPMessage", ArtistMessage);


Then in the JSP page the USEBEAN tag would use JSPMessage as the name of the bean to grab from the session.  I use the 0.92 JSP spec, so I use the BEAN tag, but I assume that they are similar.

Yet another way you could accomplish this is to write Java code in your .JSP page.  A JSP page builds a dynamic servlet, so you could have servlet to servlet communication.

Hope that helps!

Matt Butler

-----Original Message-----
From: Alexander Yavorskiy [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 29, 1999 10:53 AM
To: [EMAIL PROTECTED]
Subject: *** Sharing beans between Servlets and JSPs ***


Hi,
The entry point for my JSP/Servlet application is a single servlet. Its
purpose is to instantiate and initialize a few beans that should persist for
the lifetime of the app. I would like to make these beans available to all
JSP pages through the USEBEAN tag with an application lifespan. Does anyone
know a syntax for instantiating such beans in a servlet  such that USEBEAN
tag can locate and reference them?

Thanks,
Alex

PS
We are using JRun/0.96 JSP spec.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to