Hi Thomas,
It is still not working.

The following is the source code for both the servlets.
Let me know if i'm still missing something....

/////////////HelloWorldExample2(Servlet1) Code/////////
public class HelloWorldExample2 extends HttpServlet {
    public void service(HttpServletRequest request, HttpServletResponse
response)
    {
        try
        {
            PrintWriter out = response.getWriter();
            response.setContentType("text/html");

getServletConfig().getServletContext().getRequestDispatcher("/examples/servlet/HelloWorldExample3").forward(request,

            response);
            out.flush();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

///////////////////End  HelloWorldExample2///////////////////

//////////////////// HelloWorldExample3(Servlet2) Code ////////////////
public class HelloWorldExample3 extends HttpServlet {
    public void service(HttpServletRequest request,
        HttpServletResponse response)
        throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("Hello World Servlet Three");
    }
}

////////////End  HelloWorldExample3 ////////////

"Thomas, Omar" wrote:

> Vasu,
>
>      Well the ServletConfig object is an implicit object in the service
> method so don't have to create it... what you can try to do is ... instead
> of instantiating ServletConfig and ServletContext.. try
>
> //////////////Code Servlet 1 - service() method//////////
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
> getServletConfig().getServletContext().getRequestDispatcher("/examples/servl
> et/HelloWorldExample3").forward(req, resp);
> out.flush();
> //////////////End Code///////////////
>
> this will work ..
>
> -----Original Message-----
> From: Vasu Y [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 08, 2000 2:20 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Servlet-to-Servlet Communication
>
> Revathi,
>  I tried RequestDispatcher.forward(request, response), but doesn't work.
> The following is the code I tried on Tomcat 4.
> Both the servlets are deployed on the same machine.
>
> Can u tell me if I'm missing something....
>
> //////////////Code Servlet 1 - service() method//////////
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
> ServletConfig config = getServletConfig();
> ServletContext context = config.getServletContext();
> RequestDispatcher dispatcher =
> context.getRequestDispatcher("//examples//servlet//HelloWorldExample3");
> dispatcher.forward(request, response);
> out.flush();
> //////////////End Code///////////////
>
> //////////////Code Servlet2 - service() method//////////////
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
> out.println("Hello World Servlet Three");
> //////////////End Code///////////////
>
> Thanks,
> Vasu
>
> ___________________________________________________________________________
> 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
>
> ___________________________________________________________________________
> 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

___________________________________________________________________________
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