SetAttribute is a nice way to share objects between servlets. Pity it is introduced in 2.1 and Jserv only supports 2.0 at the moment. Singletons are the best way to go for the time being.
 
I too would like to use redirect but it just seems flaky under netscape. At the moment I am using getServlet since I really have no choice (take my word for this). With the forward or include from the new API is it possible to add arguments to the request object?
 
Eg. if I used redirect it would be:
    response.sendRediect( absoluteURL+'?' + arg1 + '=' + argvalue);
 
What would be the equivalent with JSDK2.1 (i.e. with the forward routine)?
 
Another question: what is the security risk of calling getServlet. It states it but I have never come across a real explanation.
-----Original Message-----
From: Alexandre Vermeerbergen <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Friday, September 03, 1999 7:52 AM
Subject: Réf. : How to call another servlet(from a servle t) without using redire ct.


Hi Stephane,
     You should'nt call directly another servlet's methods because the
getServlet() method which may have answered to you question (see
http://java.sun.com/docs/books/tutorial/servlets/communication/other-servle
ts.html) is deprecated since Servlet specifications version 2.0.
     The "clean" solution seems to be based on resources shared by servlets
(see
http://java.sun.com/docs/books/tutorial/servlets/communication/attributes.h
tml).
     Yet... you should ask yourselves why do you want to call another
servlet's methods?
  => in order to share/resure business logic? then a better design is to
isolate your common business logic in a common class, a non-visible
JavaBean or a session bean if you want to make it modern
  => in order to include or forward the response of the other servlet ?
Then you must use the RequestDispatcher object : see
http://java.sun.com/docs/books/tutorial/servlets/communication/request-disp
atcher.html

     Some older servlet engines may not implement 'RequestDispatcher'. In
this case you are unfortunately obliged to cheat by using the deprecated
getServlet() call, or you can implement a king of 'proxy' in your calling
servlet by directly playing at the URL connection level, but in this case
do not forget to transmit the session ID cookie (which name is
engine-dependent, until Servlet2.2 specifications...).
     Alex.






"Cote, Stephane" <[EMAIL PROTECTED]> le 09/01/99 05:10:42 PM

Veuillez répondre à "A mailing list for discussion about Sun Microsystem's
      Java              Servlet API Technology."
      <[EMAIL PROTECTED]>

Pour :    [EMAIL PROTECTED]
cc :   (ccc : Alexandre VERMEERBERGEN/dassault-systemes)
Objet :   How to call another servlet(from a servlet)  without using redire
      ct.


Reply via email to