- From: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>
- Date: Thu, 09 Oct 1997 17:37:28 +0200
- To: pazandak@OBJS.com
- cc: www-jigsaw@w3.org, Benoit.Mahe@sophia.inria.fr
> In a subclass of FileResource I may determine that I want to redirect the request to
> another file -- is this possible? Yes, I can change the filename & return the content of the
> other file, but this would bypass security & any file processing that may be done earlier in
> the request process.
>
> What is the proper way to redirect an HTTP request (in Jigsaw)?
>
> Paul.
> --
>
> ********************************************************************
> Paul Pazandak pazandak@objs.com
> Object Services and Consulting, Inc. http://www.objs.com
> Minneapolis, Minnesota 55420-5409 612-881-6498
> ********************************************************************
>
>
If you want to make a HTTP redirect with the MOVED_TEMPORARILY or
MOVED_PERMANENTLY reply code, look at w3c.jigsaw.resources.RelocateResource
otherwise the way to do an internal redirect could be :
public Reply perform(Request request)
throws HTTPException, ClientException
{
Reply reply = null;
httpd server = getServer();
String target = "/foo/bar/toto.html"; //the resource to redirect the
request
request.setReferer(getURLPath());
try {
request.setURL( new URL(server.getURL(), target));
} catch (MalformedURLException ex) {
Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
error.setContent("<html><head><title>Server Error</title>"+
"</head><body><h1>Server misconfigured</h1>"+
"<p>The resource <b>"+getIdentifier()+"</b>"+
"has an invalid target attribute : <p><b>"+
getTarget()+"</b></body></html>");
throw new HTTPException (error);
}
return server.perform(request);
}
- Benoît Mahé -------------------------------------------------------
World Wide Web Consortium bmahe@w3.org, bmahe@sophia.inria.fr
Architecture domain - Jigsaw Team tel : 04 93 65 79 89
---------------------------------------------------------------------
Received on Thursday, 9 October 1997 11:40:15 UTC