Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get previous page URL from request using a servlet

How do I get the previous page URL from request using a servlet. For example, I'm from the index.html and I submitted a form from index, how do I get the index.html URL and use it in a servlet?

request.getRequestURL()

getRequestURL doesn't work since it only returns the URL of the servlet.

like image 631
Jessie Avatar asked Oct 18 '25 12:10

Jessie


2 Answers

Write in your Servlet the following code

String url = request.getHeader("referer");

This worked in my case.Hope it works for you as well

like image 200
Nishit Shah Avatar answered Oct 21 '25 01:10

Nishit Shah


I think request.getAttribute("javax.servlet.forward.request_uri") this works.

like image 20
Rohith K Avatar answered Oct 21 '25 02:10

Rohith K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!