The documentation on HttpServletRequest is very poor, and this fills in a critical set of facts that you need to know to write a TomCat application.
The HttpServletRequest object will return the path to the current request with the following methods:
getContextPath()
getContextPath
()
getPathInfo()
getPathInfo
getPathTranslated()
getPathTranslated
getQueryString()
getQueryString
getRequestURI()
getRequestURI
getRequestURL()
getRequestURL
getServletPath()
getServletPath
Imagine you have a tomcat server installed at http://server:8080/arrow-up-right
Imagine you install an application in this server at “myapp”
That application has a servlet mounted at “servlet1”
The user then makes a request:
http://server:port/myapp/servlet1/path/file.doc?q1=foo&q2=bar
Here is the map of how the various functions decode this:
Last updated 6 years ago
Was this helpful?