Here is my jsp file:
<%@ page contentType="text/plain" %>
<%@ page pageEncoding="UTF-8"%><%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:out value="${fn:replace(pageContext.request.requestURL, pageContext.request.requestURI, '')}" /><c:out value="${model.uri}" />
I am getting the error
The method replace(String, String, String) in the type Functions is not applicable for the arguments (StringBuffer, String, String)
I have tried pageContext.request.requestURL.toString() but toString() is apparently not a method. Any suggestions?
StringBuffer#toString()
is definitely the right method to call. The problem is calling it using EL. You can convert it to string using <c:set>
as described in this answer.
<c:set var="url">${pageContext.request.requestURL}</c:set>
<c:out value="${fn:replace(url, pageContext.request.requestURI, '')}" />
That said, I think there's a better way to get the output string you want that doesn't use fn:replace
.
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