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"?
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.
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.
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.
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']}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With