tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Feng-Chang" <mar...@cht.com.tw>
Subject Re: how two web applications share a java bean object ?
Date Fri, 18 Jul 2003 02:38:51 GMT
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" <sankara@answerpal.com>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
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("<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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message