How to get the previous page URL from request in servlet after dispatcher.forward(request, response)
String referer = request.getHeader("Referer");
response.sendRedirect(referer);
SEE: Link to forum answer
Try using
request.getAttribute("javax.servlet.forward.request_uri")
See
https://tomcat.apache.org/tomcat-9.0-doc/servletapi/constant-values.html
and
How to get the url of the client