1、获得ContextPath

在Servlet中,用request.getContextPath();方法

在JSP中,用${pageContext.request.contextPath},这个其实等价于pageContextPath.getRequest().getContextPath();