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.



Hi all.


        How can you call a certain methods on a servlet (by another
servlet)
without using redirect.
This methods would return something.(String) or Stream

thanks.




                      ,,                    Stephane DeCoeli Cote
                    `  >                  [EMAIL PROTECTED]
 ||                  ~                 || w (925) 730-3717
|||=oOOo=====oOOo=|||
 ||             \  /||\  /            ||
                  \/ || \/
                     /\


Title: How to call another servlet(from a servlet) without using redirect.

Hi all.

       
        How can you call a certain methods on a servlet (by another servlet) without using redirect.
This methods would return something.(String) or Stream

thanks.




                      ,,                    Stephane DeCoeli Cote
                    `  >                  [EMAIL PROTECTED]
 ||                  ~                 || w (925) 730-3717
|||=oOOo=====oOOo=||| 
 ||             \  /||\  /            ||  
                  \/ || \/         
                     /\            

Reply via email to