This JSP example shows how to find the context path or base url of a web application in Java.
The contextPath expression or getContextPath method from the Request object of the JSP page holds root or base URL of the running Java web application.
1 2 3 4 5 6 7 8 9 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>JSP - Context Path</title> </head> <body> Web Application Context Path = ${pageContext.request.contextPath} </body> </html> |