Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 93565 invoked from network); 23 Apr 2002 11:09:52 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 23 Apr 2002 11:09:52 -0000 Received: (qmail 10685 invoked by uid 97); 23 Apr 2002 11:09:45 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 10635 invoked by uid 97); 23 Apr 2002 11:09:44 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 10599 invoked by uid 50); 23 Apr 2002 11:09:43 -0000 Date: 23 Apr 2002 11:09:43 -0000 Message-ID: <20020423110943.10598.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: tomcat-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 8409] New: - HttpServletRequest.getRequestURI() returns wrong URI when forwarded with RequestDispatcher.forward() X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8409 HttpServletRequest.getRequestURI() returns wrong URI when forwarded with RequestDispatcher.forward() Summary: HttpServletRequest.getRequestURI() returns wrong URI when forwarded with RequestDispatcher.forward() Product: Tomcat 4 Version: 4.0.3 Final Platform: PC OS/Version: Windows 9x Status: NEW Severity: Normal Priority: Other Component: Catalina AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: thomas@botany.ch When forwarding a HttpServletRequest with RequestDispatcher.forward(HttpServletRequest req, HttpServletResponse res), calling - in the servlet the request is forwarded to - the method HttpServletRequest.getRequestURL() returns the request URL of the CALLING servlet whereas the method HttpServletRequest.getRequestURI() returns the request URI of the CALLED servlet. Example: Test servlet 1: The servlet ExceptionSource throws an exception and forwards to the servlet ExceptionHandler. public class ExceptionSource extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { String s = null; s.charAt(0); } catch (NullPointerException e) { RequestDispatcher dispatcher = request.getRequestDispatcher("/servlet/ExceptionHandler"); dispatcher.forward(request, response); } } } Test servlet 2: The servlet ExceptionHandler calls HttpServletRequest.getRequestURL() and HttpServletRequest.getRequestURI(). public class ExceptionHandler extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/plain"); PrintWriter out = response.getWriter(); out.println("request URL: " + request.getRequestURL()); out.println("request URI: " + request.getRequestURI()); } } The output of ExceptionHandler is: request URL: http://localhost/servlet/ExceptionSource request URL: /servlet/ExceptionHandler -- To unsubscribe, e-mail: For additional commands, e-mail: