RequestDispatcher issue?


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.

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

    say there are 2 servlet URL:

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

    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