Craig,

Thanks for all the explanation about this. I think I need to seek
further advice from here:)

say, you have a connection pool to hold all the connections to the
database for different threads. I was trying to write my own
connection pool, and let other servlets share this information. how do
you manage to do this?

Thanks again!

Emily

----Original Message Follows----
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>

~{4tM74tDT~} PapayaHead wrote:

> any alternative method to get a reference to the servlet since
> getServlet() is deprecated in jsdk2.1 new release?
>
> Thanks!
>

Yes ... That is what the RequestDispatcher concept is all about.
Let's say
that you have a servlet that did some processing, stashed results in
the
session, and wants to forward to a different servlet (or JSP page, for
that
matter) to display the results.  You would need something like this:

    RequestDispatcher rd =
getServletContext.getRequestDispatcher("/servlet/otherservlet");
    rd.forward(req, res);

where "req" and "res" were the arguments to your doGet() or doPost()
method.
If you wanted to include the output from the other servlet
(essentially a
programmatic server side include), you would do this instead:

    RequestDispatcher rd =
getServletContext.getRequestDispatcher("/servlet/otherservlet");
    rd.include(req, res);

If you were using the getServlet() mechanism to provide access to a
servlet
for shared data access (despite all the warnings in the spec about
this being
a dangeroius thing to do), you are going to have to redesign your
application.  The easiest way to provide shared access to data objects
across
multiple servlets is to store them in the servlet context itself,
using
ServletContext.setAttribute().  You can access these objects from
other
servlets (in the same context) with ServletContext.getAttribute().

Craig McClanahan

______________________________________________________________________
_____
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




______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
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

Reply via email to