How to get previous page URL from request using a servlet

半世苍凉 提交于 2020-01-30 07:33:07

问题


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.


回答1:


Write in your Servlet the following code

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

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




回答2:


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



来源:https://stackoverflow.com/questions/29874539/how-to-get-previous-page-url-from-request-using-a-servlet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!