request.getSchema(), returns the protocol used by the current connection, generally the application returns http, SSL returns https ;
request.getServerName(), returns the name of the server where the current page is located;
request.getServerPort(), returns the port used by the server where the current page is located, 80;
request.getContextPath(), returns the name of the application where the current page is located.
getContextPath() is a way to get the path in jsp, so what is the result obtained? What are the other ways of getting the path in jsp? Intrigued, listen to the breakdown:
Take the accessed jsp as: http://localhost:8080/dmsd-itoo-exam-log-web/course/index.jsp and the project name as /dmsd-itoo-exam-log-web as an example:
request.getContextPath(), get the project name: /dmsd-itoo-exam-log-web;
request.getServletPath(), returns the full name of the directory where the current page is located: /course/index.jsp;
request.getRequestURL(), returns the IE address bar address: http://localhost:8080/dmsd-itoo-exam-log-web/course/index.jsp;
request.getRequestURI() , returns the full path of the current page including the project name: /dmsd-itoo-exam-log-web/course/index.jsp.