Hello Everyone. Can anyone give me an example which results in a non-null value for the request attribute: javax.servlet.forward.path_info?
I've been able to get values for the other four request attributes: javax.servlet.forward.request_uri, javax.servlet.forward.context_path, javax.servlet.forward.servlet_path, and javax.servlet.forward.query_string. I forward to a page with the following code:
In the destination page, I display the request attributes as follows:
So this is fine, but no matter how I change the mappings in web.xml, and no matter what parameters I pass (in the browser address bar, or in the <jsp:forward>) I always end up with a null value for javax.servlet.forward.path_info.
I'd appreciate any help in getting a non-null value for javax.servlet.forward.path_info. Many thanks!
The reason is explained in the Servlets Specification, SRV.4.4 Request Path Elements.
Context Path: The path prefix associated with the ServletContext that this servlet is a part of. If this context is the “default” context rooted at the base of the Web server’s URL name space, this path will be an empty string. Otherwise, if the context is not rooted at the root of the server’s name space, the path starts with a’/’ character but does not end with a’/’ character.
Servlet Path: The path section that directly corresponds to the mapping which activated this request. This path starts with a’/’ character except in the case where the request is matched with the ‘/*’ pattern, in which case it is an empty string.
PathInfo: The part of the request path that is not part of the Context Path or the Servlet Path. It is either null if there is no extra path, or is a string with a leading ‘/’.
The following methods exist in the HttpServletRequest interface to access
It is important to note that, except for URL encoding differences between the
request URI and the path parts, the following equation is always true: