The Holy Java

Building the right thing, building it right, fast

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

Posted by Jakub Holý on March 24, 2014

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

Sorry, the comment form is closed at this time.

%d bloggers like this: