HttpServletRequest cheat sheet

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, and it points to a router which forwards the request to port 8080 on a server called bob with a local IP of Now we look at some properties for a request to

Property Value Notes
contextPath /app
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 doesn’t contain query
scheme http
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.

Post a Comment

Your email is never shared. Required fields are marked *