You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Juan Alvarado (Struts List)" <ju...@manduca.com> on 2002/07/31 01:10:27 UTC

Slightly off-topic

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
jalvarado@manduca.com
AOL Instant Messenger: juan2000@aol.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>