>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:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
>Sent: Thursday, July 17, 2003 7:16 AM
>To: [EMAIL PROTECTED]
>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




This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


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




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

Reply via email to