RequestDispatcher issue?

Discussions

EJB programming & troubleshooting: RequestDispatcher issue?

  1. RequestDispatcher issue? (1 messages)

    I read the doc and know that RequestDispatcher could be used in relative path and absolute path.But in realistic,I can't dispatch a request from one servlet to another which are in different web context.

    eg:
    I run 2 web server on localhost,port are 7001 and 8080 respectively

    say there are 2 servlet URL:
    http://localhost:8080/servlet/AServlet
    http://localhost:7001/BServlet

    in AServlet there is some code like:
    public void service(...) throws ... {
         RequestDispatcher rd=request.getRequestDispatcher("http://localhost:7001/BServlet");
        rd.forward(request,response);
    }

    always wrong,I hope someone could tell me why?

    Thanks a lot!
  2. RequestDispatcher issue?[ Go to top ]

    hi jerry,

    the API doc for ServletRequest.getRequestDispatcher says

    "The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. "

    u might want to use ServletContext.getRequestDispatcher instead

    rgds,
    Mani