HttpServletRequest request = (HttpServletRequest) req; String contextPath = request.getContextPath();
String contextPath = req.getContextPath();In this example, the getContextPath method is called on the req object directly without casting it to a HttpServletRequest first. The javax.servlet.http package contains the HttpServletRequest and HttpServletResponse interfaces that are used to interact with HTTP requests and responses.