Many HttpServletRequest
properties can be confusing, so I decided to create this cheat sheet. (Properties can have similar names, some properties contain delimiters and some don’t, etc.) Let’s say your domain is domain.com
, and it points to a router which forwards the request to port 8080 on a server called bob
with a local IP of 192.168.0.100. Now we look at some properties for a request to http://domain.com/app/servlet/extra?query
.
Property | Value | Notes |
---|---|---|
contextPath | /app | |
localAddr | 192.168.0.100 | |
localName | bob | |
localPort | 8080 | |
pathInfo | /extra | may be null |
protocol | HTTP/1.1 | protocol is NOT http or https, that is scheme |
queryString | query | may be null |
requestURI | /app/servlet/extra | doesn’t contain query |
requestURL | http://domain.com/app/servlet/extra | doesn’t contain query |
scheme | http | |
serverName | domain.com | |
serverPort | 80 | |
servletPath | /servlet |
Note that I wanted to keep it smallish, so I’ve only included useful, non-obvious String and int properties. For instance, pathTranslated is useless, so I left it out.