HttpServletRequest Demystified

Today is about the tenth time I’ve needed to redirect to a slightly modified version of the current URL. So, I have to piece together a URL from pieces in an HttpServletRequest. And I can never remember which piece is which. I know, I know, the difference between “servletPath” and “pathInfo” should be intuitively obvious to me. So now, for the last time, here is what the pieces mean, for an example URL:

  • protocol – “HTTP/1.1” (you’ll have to convert this back to http or https, for example)
  • serverName – “”
  • serverPort – 8080
  • contextPath – “/appname”
  • servletPath – “/servletname”
  • pathInfo – “/my/path”
  • queryString – “name=value”

Not looking at all of these values now, so some might be slightly off – please post a comment to correct me.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: