I want to call request.getContextPath()
inside a JSP tag which extends SimpleTagSupport
, is there any way to do it?
The JSP request is an implicit object of type HttpServletRequest i.e. created for each jsp request by the web container. It can be used to get request information such as parameter, header information, remote address, server name, server port, content type, character encoding etc.
The JSP request can be defined as an implicit object is an instance of "HttpServletRequest" and is formed for all JSP requests through the web container. This JSP request gets request information like a parameter, remote address, header information, server port, server name, character encoding, content type, etc.
getQueryString() – Used for getting the query string associated to the JSP page URL.
First get the PageContext
by the inherited SimpleTagSupport#getJspContext()
and then get the HttpServletRequest
by PageContext#getRequest()
.
PageContext pageContext = (PageContext) getJspContext();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With