HTTP servlet request url components
July 26, 2010 15:55:41 Last update: March 28, 2012 15:28:02
Given the URL:
This would be the output of the various method calls on
http://www.mydomain.com/myWebApp/theServlet/p1/p2/p3;sid=123?param=abc
This would be the output of the various method calls on
HttpServletRequest:
String scheme = request.getScheme(); // http String serverName = request.getServerName(); // www.mydomain.com int portNumber = request.getServerPort(); // default 80 String contextPath = request.getContextPath(); // /myWebApp String servletPath = request.getServletPath(); // /theServlet String pathInfo = request.getPathInfo(); // /p1/p2/p3;sid=123 String requestURI = request.getRequestURI(); // /myWebApp/theServlet/p1/p2/p3;sid=123 String queryString = request.getQueryString(); // param=abc boolean isSecure = request.isSecure(); // false, would be true if protocol is HTTPS