Bug 23211 - ServletContext,getRequestDispatcher throws exception for invalid path instead of returning null
Summary: ServletContext,getRequestDispatcher throws exception for invalid path instead...
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: 4.1.24
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-17 11:40 UTC by Stefan Hepper
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Hepper 2003-09-17 11:40:29 UTC
when calling ServletContext,getRequestDispatcher("invalidPath") the method
throws an exception. However, the servlet javadocs specify to return null in
that case.

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String path)

    Returns a RequestDispatcher object that acts as a wrapper for the resource
located at the given path. A RequestDispatcher object can be used to forward a
request to the resource or to include the resource in a response. The resource
can be dynamic or static.

    The pathname must begin with a "/" and is interpreted as relative to the
current context root. Use getContext to obtain a RequestDispatcher for resources
in foreign contexts. This method returns null if the ServletContext cannot
return a RequestDispatcher.
Comment 1 Tim Funk 2003-09-17 11:48:26 UTC
Every URL is ultimately mapped to the default servlet which is mapped to / if no
other servlet matches.

The default servlet is the one throwing the exception.