I am working on a struts app and need to accomplish the following...
Can anyone tell me (if they know) what I have to do to capture the page the
user requested.
Example:
I have in my web.xml:
<error-page>
<error-code>404</error-code>
<location>/error404/go.jsp</location>
</error-page>
In my go.jsp I want to retrieve the url the user requested. Since I am bound
to the 2.2 API, I can't call request.getRequesURL(). So I looked at the
source for that method and used it in my page.
StringBuffer url = new StringBuffer();
String scheme = request.getScheme();
int port = request.getServerPort();
if (port < 0)
port = 80; // Work around java.net.URL bug
url.append(scheme);
url.append("://");
url.append(request.getServerName());
if ((scheme.equals("http") && (port != 80))
|| (scheme.equals("https") && (port != 443))) {
url.append(':');
url.append(port);
}
url.append(request.getRequestURI());
out.print("The URL requested was " + url.toString());
My problem is that the result of the above code gives me the name of the
error handler page (http://www.somewebsite.com/error404/go.jsp), when in
reality I need the page the user requested.
Ex: http://www.somewebsite.com/hadhfad.html (Doesn't exist)
internally tomcat forwards to /error404/go.jsp. In that page is where I need
to retrieve the URL the user
requested(http://www.somewebsite.com/hadhfad.html). But with the code above
I get http://www.somewebsite.com/error404/go.jsp.
Does anyone know how to accomplish this with the servlet 2.2 API.
Thanks
**********************************************
Juan Alvarado
Internet Developer -- Manduca Management
(786)552-0504
[EMAIL PROTECTED]
AOL Instant Messenger: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>