title: How to show the requested URL in a JSP error page?
body: <p>In the error page I would like to display the URL what the user requested.</p>
  
  <p>In my <strong>web.xml</strong>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                              http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
          id="WebApp_ID"
          version="3.0"&gt;
  
      &lt;display-name&gt;MyStuff&lt;/display-name&gt;
  
      &lt;error-page&gt;
          &lt;error-code&gt;404&lt;/error-code&gt;
          &lt;location&gt;/WEB-INF/error-404.jsp&lt;/location&gt;
      &lt;/error-page&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>This will forward to <strong>error-404.jsp</strong>, and here is the content of that file:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
      &lt;title&gt;Page Not found&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p align="center"&gt;
      &lt;%
          out.println("Requested resource: " + request.getRequestURL()+ " not found");
      %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br>
  The problem it is the <code>request.getRequestURL()</code> need to be changed, but don't know the keyword for what to search.</p>
  
  <p>When I start the browser for <code>http://localhost:8080/MyStuff</code> then I get the following error: </p>
  
  <p><strong><code>Requested resource: http://localhost:8080/MyStuff/WEB-INF/error-404.jsp not found</code></strong></p>
  
  <p>How to solve this?</p>