I'm using the servlet which redirects me with the help of
dispatcher.forward(request, response);
in the end. But after this I want to get the page(path) from which I was redirected to use it in next servlet command(to go to previous page). How could I get it? Or previous URL is not contained in request parameters and I should add it myself? Will be very grateful for your help.
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
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