Vivek Vivek - 1 year ago 134
Java Question

how to get URL from address bar in JSP

Lets say I hit


and this internally redirects me to custom 404.jsp page, But URL remain same in address bar.

I tried this code -
<%= request.getAttribute("javax.servlet.forward.request_uri") %>;
and it's returning me the path of 404.jsp

How can I get the entered URL which is there in address bar?

Answer Source

I think you were close. javax.servlet.forward.request_uri is for normal forwarding, but for 404, you need javax.servlet.error.request_uri.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download