> Daniel Liu wrote:
>
> > Is there any way that shares objects among different servlets?
> >
> > Thanks.
> [...]
I just try to add a note from the directions of several books and
several emails in Servlet-List:
* HttpSession.setAttribute(...)/getAttribute(...)
but from my working with jakarta-tomcat-4.0-b1(StandAlone),
I find it works in the same webapp, but from my work, it seems
it doesn't work between two webapps in the same Servlet
container in the same computer.
* ServletContext.setAttribute(...)/getAttribute(...)
same with above, from my work, it only work in the same
webapp.
* Helper class
put the object in a field of MyHelper class in one MyServlet,
and get this object from this field in another MyServlet.
same with above, from my work, it only work in the same
webapp. because Ifind:
- if this field is a static field, but I find diffrent wepapps
use different classloader to load MyHelper, so in fact
what we get is not what we put if between twp webapps.
- if this field is not a static field, the reasons is similar.
* if we don't insist on using "OO tech", I guess we also
can use:
- Hidden Form Fields
- URL Rewritting
- Cookies(directly)
I guess such way is:
MyServlet0 Parse the object, and put "info" into browser,
MyServlet2 get info from browser :-)
* and I guess perhaps there are other non-standard way,
for example:
- put the object in a static field in MyServlet0, and MyServlet1
directly access this field.
- put the object in a non-static field in MyServlet0, and in
MyServlet0, put "this" into ServletContext, and in
MyServlet1, get this reference(to Servlet0) from
ServletContext, then access this field.
- a Not good way: MyServlt0 call Bo with a phone, and Bo call
MyServlt1... //haha :-)
Bo
Feb.15, 2001
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html