Re: Using RewriteFilter defined in web.xml within application
"Tim Maurer" <[email protected]> Mon, 19 Jun 2006 12:35:54 -0700
| Newsgroups | gmane.text.xml.resin.user |
|---|---|
| Message-ID | <[email protected]> |
Beautiful! Thanks Keith, exactly what I needed. Tim On 6/19/06, Keith Fetterman <[email protected]> wrote: > Tim, > > I am not sure what you asking for here. But just in case, maybe this > will be helpful. You can retrieve the original URI for a request using > request attributes if you have used the RequestDispatcher's forward or > include functionality. Take a look at pages 65 and 66 in the Servlet > 2.4 specification. Here is an excerpt from the document for the > attribute parameters for a forward: > > > SRV.8.4.2 Forwarded Request Parameters > Except for servlets obtained by using the getNamedDispatcher method, a > servlet that has been invoked by another servlet using the forward > method of RequestDispatcher has access to the path of the original > request. The following request attributes must be set: > > javax.servlet.forward.request_uri > javax.servlet.forward.context_path > javax.servlet.forward.servlet_path > javax.servlet.forward.path_info > javax.servlet.forward.query_string > > These attributes are accessible from the included servlet via the > getAttribute method on the request object and their values must be equal > to the request URI, context path, servlet path, path info, and query > string of the included servlet, respectively. If the request is > subsequently included, these attributes are replaced for that include. > If the included servlet was obtained by using the getNamedDispatcher > method, these attributes must not be set. > > There are similar parameters for an include (page 65.) > > > Tim Maurer wrote: > > Silly of me to think even if I do grab the instance of my > > RewriteFilter it'd be of any use. Nevermind that. > > > > Still, though, I'd like to retrieve the browser's original pre-rewrite > > request URI without having to manually reverse the rewrites. > > > > Tim > > > > On 6/14/06, Tim Maurer <[email protected]> wrote: > >> Hi all, > >> In my web app I'd like to use request.getRequestURI() to dynamically > >> construct URIs for various redirection purposes, but I'm > >> inconvenienced by the fact that my app makes use of a RewriteFilter > >> and request.getRequestURI() returns the true servlet's URI as opposed > >> to the pre-rewrite URI used in the request. > >> > >> Am I missing an obvious way of making use of the RewriteFilter within > >> my app? I've looked at com.caucho.server.webapp.Application for any > >> hints in grabbing the filter from the context, but I'm stumped. > >> > >> Here's an example of a workflow in my app where I'd like this to work: > >> > >> 1. Unauthenticated user attempts to access a restricted resource > >> 2. Servlet redirects user to login page, appending original request > >> URI as a query parameter > >> 3. User logs in, servlet redirects to originally requested URI via the > >> query param > >> > >> Thanks for any help, > >> Tim > >> > > >