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

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


URL METHODS BREAKDOWN (JavaEE 6):
- 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

Tags: webdev java


Copyright © 2024 Jakub Holý
Powered by Cryogen
Theme by KingMob