Vasu Yalavarthi wrote:

> 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 ////////////
> [...]

Hi :-)  I am not sure, but I find a sample in a book-"core Servlets and
Java Server Pages"(ISBN:0-13-089340-4),   from page 355:

  *
    ...
    RequestDispatcher dispatcher =
    getServletContext().getRequestDispatcher(address);
    dispatcher.forward(request, response);
    ...

    So it seems that you don't need to use "getServletConfig()".

  *
    I just guess you don't need the following in your HelloWorldExample2:
            ...
            PrintWriter out = response.getWriter();
            response.setContentType("text/html");
            ...
            out.flush();
            ...

   * is "/examples/servlet/HelloWorldExample3" right? can you access it
      directly(without RequestDispatcher from HelloWorldExample2)?



have a nice weekend:-)


Bo
Dec.09, 2000

___________________________________________________________________________
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