CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 1999
    Location
    India.
    Posts
    81

    Servlet Servlet communication

    How to send data(values in variables) from servlet1 to servlet2?
    & how to read data from servlet2 sent by servlet1?


  2. #2
    Join Date
    Dec 1999
    Location
    Chonghe, Taipei County, Taiwan, R.O.C.
    Posts
    231

    Re: Servlet Servlet communication

    Suppose that you have two servlet, servletA and servletB. These two servlet have been initialized
    in the servlet context. Suppose that servletA want to access the data in the servletB It can get the
    servletB via ServletContext and access the data in the servletB. You may consider the following
    code snippet :

    ServletContext context = getServletContext();
    ServletB servletb = (servletB)context.getServlet("servletB");
    String some_data = servletb.getSomeData();
    System.out.println("some data is : " + some_data);



    I never try this code snippet.
    For more information, you may consider the content in the Java Server Programming by wrox,
    or Java Servlet Programming by oreilly.
    good luck,
    Alfred Wu



  3. #3
    Join Date
    Jun 2000
    Posts
    2

    Re: Servlet Servlet communication

    Hi Monika,

    You may use Servlet Chaining Mechanism (and read Header Names and Header in 2nd servlet) for Chaining Output from 1st Servlet to 2nd one and so on.

    C Servlet Programming by Karl Moss for more details and sample code.

    Srinivas,
    Columbus



  4. #4
    Join Date
    May 2000
    Location
    NJ,USA
    Posts
    64

    Re: Servlet Servlet communication

    Hi, U can do in this way, if ur sending 1 or 2 variables..
    If this is ur form in servlet1.. then,
    form name="" method="" action="http://localhost:8080/servlet/Servle...e&Name2=value2...
    And in ur servlet2, access these values by,
    String str1 = req.getParameter("Name");
    String str2 = req.getParameter("Name2");

    Hope this will help u

    Sreeni


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured