HttpServletRequest: requestURI/requestURL/contextPath/servletPath/pathInfo/queryString

I never remember what some of these HttpServletRequest methods return so here is an example:

- requestURL  = http://localhost:8080/myapp/users/profile.xhtml
- requestURI  = /myapp/users/profile.xhtml = contextPath + servletPath + pathInfo
- contextPath = /myapp = the first segment after hostname (unless the app runs and the root app with context /)
- servletPath = /users/profile.xhtml (part after contextPath to the servlet that handled the request)
- pathInfo    = null (what remains after servletPath up to the queryString; would return '/dummy' if the url was '.../profile.xhtml/dummy?id=007')
- queryString = id=007

Published by Jakub Holý

I’m a JVM-based developer since 2005, consultant, and occasionally a project manager, working currently with Iterate AS in Norway.