The serlvet spec said:
Except for
servlets obtained by using the getNamedDispatcher
method, a servlet that has been invoked by another servlet
using the include method ofRequestDispatcher has access to
the path by which it was invoked.The following request attri-
butes must be set:
javax.servlet.include.request_uri
javax.servlet.include.context_path
javax.servlet.include.servlet_path
javax.servlet.include.path_info
javax.servlet.include.query_string
However, when I tried, I found "javax.servlet.include.path_info"
and "javax.servlet.include.query_string" never set, even though
the query URI contains path info and query
string.
On the other hand, when forwarding, the "javax.servlet.forward.
path_info" and "javax.servlet.forward.query_string" are set when
the URI contains path info and query string.
I don't know what's wrong here. And It's the same behavior under
Tomcat 5.5 and AppServer9.
My
test code is as following, and the mapping is:
Forwarder -> /Forwarder/*
Includer -> /Includer/*
Target -> /Target