I am running Apache 2.2 with Tomcat 6 and have several layers of URL rewriting going on in both Apache with RewriteRule and in Tomcat. I want to pass through the original REQUEST_URI that Apache sees so that I can log it properly for "page not found" errors etc.
In httpd.conf I have a line:
SetEnv ORIG_URL %{REQUEST_URI}
and in the mod_jk.conf, I have:
JkEnvVar ORIG_URL
Which i thought should make the value available via request.getAttribute("ORIG_URL")
in Servlets.
However, all that I see is "%{REQUEST_URI}"
, so I assume that SetEnv doesn't interpret the %{...}
syntax. What is the right way to get the URL the user requested in Tomcat?
Use:
Use the
getRequestURI()
andgetRequestURL()
(and perhaps thegetQueryString()
) methods of theHttpServletRequest
class.