Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get URL of page requested that caused a 404

Tags:

jsp

How would I get the URL of the page that was requested that caused the 404 error?

For example, I type I go to http://example.com/path/does/not/exist/index.jsp I already have a custom 404 page but how would I go about retrieving the URL mentioned above so that I can display it with a message similar to "The url http://example.com/path/does/not/exist/index.jsp does not exist"?

like image 819
alexcoco Avatar asked Feb 09 '11 17:02

alexcoco


People also ask

How do I find my 404 URL?

Google Search Console: You will find a list of all 404 pages by logging into your Google search console account and going to Diagnostics > Crawl Errors. After you click on “Not Found”, a list of all the urls that result in a 404 error will appear.

How do you solve not found the requested URL was not found on this server?

You may receive a 404 error because the page did not load properly. Refreshing or reloading the webpage may fix the issue. You may refresh the page by clicking the refresh button at the top of your web browser or pressing the F5 button on your keyboard.

What does error 404 Mean while accessing a URL?

The 404 code means that a server could not find a client-requested webpage. Variations of the error message include "404 Error," "404 Page Not Found" and "The requested URL was not found." This 404 error page shows the user the error code, what it means and potential ways to navigate around it.


1 Answers

If forward was used to go to the error page, you can obtain the original request URL by

request.getAttribute("javax.servlet.forward.request_uri")

or by EL

${requestScope['javax.servlet.forward.request_uri']}
like image 146
Bozho Avatar answered Oct 05 '22 08:10

Bozho