The getRequestDispatcher method takes a String argument describing a path within the scope of the ServletContext. This path must be relative to the root of the ServletContext and begin with a �/�. The method uses the path to look up a servlet, using the servlet path matching rules in Chapter SRV.11, �Mapping Requests to Servlets�, wraps it with a RequestDispatcher object, and returns the resulting object. If no servlet can be resolved based on the given path, a RequestDispatcher is provided that returns the content for that path.
Can someone explain me why these are not contradictory?
If no servlet can be resolved based on the given path, a RequestDispatcher is provided that returns the content for that path.
Its not necessary that the argument to the request dispatcher is always a servlet. It may be another resource like HTML files e.g.
Hence is such a scenario, the HTML page is rendered. And of course, if getRequestDispatcher cannot return a RequestDispatcher, it will return nothing(null). Please let me know if this clarifies your doubt.
1)In first case the request processor will return null bcoz it found no file that RequestProccessor can return to be operated upon e.g. if you pass directory in the path.
2)but if their is path that can be resovled as a valid html content it will return the content (it can be servlet/html etc).