have a look there :
http://www.fwd.at/tomcat/sharing-session-data-howto.html
----- Original Message -----
From: "martin(Feng-Chang)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 17, 2003 1:16 PM
Subject: how two web applications share a java bean object ?
Dear All:
I set a java bean in one web application, whether add this bean to session
or ServletContext.
I can't get it in the other web application.
How does a bean transmit between different web applications in Tomcat ?
Web Application 1
------------------------ servlet1 --------------------------------
MyBean bean1 = new MyBean();
bean1.setName("martin");
bean1.setAge(25);
ServletConfig config = getServletConfig();
ServletContext sc = config.getServletContext();
sc.setAttribute("UserInfo",bean1);
----------------------------------------------------------------------
Web Application 2
----------------------- servlet2 ------------------------------------
ServletContext sc = getServletContext();
MyBean bean2 = (MyBean)sc.getAttribute("UserInfo");
resp.setContentType("text/html; charset=Big5");
PrintWriter out = resp.getWriter();
out.println("<h2>this is Get servlet in </h2>");
out.println(req.getRequestURI());
out.println("Name : "+bean2.getName());
out.println("Age : "+bean2.getAge());
out.close();
---------------------------------------------------------------------
servlet 2 show nothing ....
Thank a lot.
Best regards,
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]