0
String Refer=request.getServerName()+ ":" + request.getServerPort()+ request.getContextPath();
String URL = request.request.getRequestURL();
String URL = request.request.getRequestURI();

I have tried to get the current location URL using these commands and i have failed to retrieve the exact location. In java script if i use Document.href, i could achieve my task but if i wanted to the same in java, i cannot retrieve as same ad document.href. I am calling a *.do action where xml will populate the JSP. If i used request.request.getRequestURL i get the jsp location which not the same as document.href

  • Possible duplicate of [How do you detect the URL in a Java Servlet when forwarding to JSP?](https://stackoverflow.com/questions/1030798/how-do-you-detect-the-url-in-a-java-servlet-when-forwarding-to-jsp) – Jozef Chocholacek Nov 24 '17 at 07:11
  • I tried. It's gives me only the JSP location but I am calling from a action. So the url display like. Www.testingsample.com/previewaction.do? But this give me .................... preview.jsp which wrong – kuhandran samudra pandiyan Nov 24 '17 at 09:10
  • So you are using Struts? Then maybe http://www.santhoshreddymandadi.com/java/struts-get-original-requested-url-when.html is the answer. – Jozef Chocholacek Nov 24 '17 at 10:19

0 Answers0