It’s always seemed a little at odds with the principles of Java that the Java Servlet Spec (2.5 version here) includes a set of magic attributes containing info about included resources, namely:
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
It’s not even specifically pointed out in the API documentation, only in the spec where it is a must for correct implementation.
This approach feels very wrong, an exposed implementation detail that clients will use and depend on. Why is this information exposed in this way?
They are actually specified in the API documentation, in the Constant Field Values part. As you see in the API documentation, you are supposed to use the constants of
RequestDispatcherinstead, e.g: