Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 35521 invoked from network); 21 Jul 2003 09:53:10 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 21 Jul 2003 09:53:10 -0000 Received: (qmail 10796 invoked by uid 97); 21 Jul 2003 09:55:53 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 10789 invoked from network); 21 Jul 2003 09:55:53 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 21 Jul 2003 09:55:53 -0000 Received: (qmail 32480 invoked by uid 500); 21 Jul 2003 09:52:38 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 33020 invoked from network); 18 Jul 2003 02:38:22 -0000 Message-ID: <005201c34cd5$b9260ed0$8e1f900a@martinp42800> From: "Feng-Chang" To: "Tomcat Users List" References: Subject: Re: how two web applications share a java bean object ? Date: Fri, 18 Jul 2003 10:38:51 +0800 MIME-Version: 1.0 X-scanner: scanned by Inflex 1.0.10 - (http://pldaniels.com/inflex/) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N YES! What I ask is how to get a bean instance in one web application that is created in another web application. Put class file in "Shared",I can use the class in different web applications,but I still CAN'T get the bean value in one web application that is set in another web application. Martin. ----- Original Message ----- From: "sankara" To: "Tomcat Users List" Sent: Thursday, July 17, 2003 9:03 PM Subject: RE: how two web applications share a java bean object ? >Put the Bean (Bean.class) in a jar (Bean.jar) and put the jar in >$CATALINA_HOME/shared/lib. This is for placing the class files shared by more than one web app. But, I think Martin is asking how to get a bean instance in one web application that is created in another web application. -A.Sankar -----Original Message----- From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com] Sent: Thursday, July 17, 2003 6:16 PM To: Tomcat Users List Subject: RE: how two web applications share a java bean object ? Howdy, Put the Bean (Bean.class) in a jar (Bean.jar) and put the jar in $CATALINA_HOME/shared/lib. And RTFM: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: martin(Feng-Chang) [mailto:martin@cht.com.tw] >Sent: Thursday, July 17, 2003 7:16 AM >To: tomcat-user@jakarta.apache.org >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("

this is Get servlet in

"); > 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: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org