On Wed, 22 Jan 2003, Bill Barker wrote:
> Date: Wed, 22 Jan 2003 22:27:54 -0800 > From: Bill Barker <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Re: Altering the request URI in a filter through > HttpServletRequestWrapper > > I haven't looked to see why you are getting this particular error message, > but the basic idea shouldn't work. Before your Filters are invoked, Tomcat > has already decided on which Servlet should handle the request at the end of > the pipeline. Changing the requestURI and servletPath at this stage > shouldn't change the mapping. > That's correct -- if you want your filter to change which servlet is actually invoked, using a RequestDispatcher.forward() is the way to go. Craig > "Jan Ploski" <[EMAIL PROTECTED]> wrote in message > 13799530.1043269459692.JavaMail.jpl@remotejava">news:13799530.1043269459692.JavaMail.jpl@remotejava... > > Hello, > > > > I would like to alter the request URI in my ServletFilter to intercept > > requests to resources that should only be available to logged in users. > > > > I have found a solution in the archive: > > > > http://www.mail-archive.com/[email protected]/msg64446.html > > > > which basically suggests to terminate the doFilter method with > > > > request.getRequestDispatcher(/* where to */).forward(request, response); > > > > and don't invoke chain.doFilter as the last step. > > > > It seems to me that it should not be done this way -- what if there > > are other legitimate filters that should process the request? > > Also, I am not sure about the semantics of calling "forward" from > > "doFilter" -- is it officially supported or maybe a "grey area" of > > the spec, and it works just by chance? > > > > Anyway, I thought that I could achieve the same by using > > a HttpServletRequestWrapper, like below: > > > > request = new HttpServletRequestWrapper(request) { > > public String getRequestURI() { > > return "/solonline/page/nosession.jsp"; } > > public StringBuffer getRequestURL() { > > return new StringBuffer( > > "http://192.168.0.1:6080/solonline/page/nosession.jsp"); } > > public String getServletPath() { > > return "/page/nosession.jsp"; } > > }; > > > > chain.doFilter(request, response); > > > > Unfortunately, the result is an error page: > > > > --- > > HTTP Status 400 - Invalid path /page/nosession was requested > > > > type Status report > > > > message Invalid path /page/nosession was requested > > > > description The request sent by the client was syntactically incorrect > > (Invalid path /page/nosession was requested). > > --- > > > > Note the ".jsp" stripped from my URI in this error message (?) > > > > I am using Apache Tomcat/4.1.18-LE-jdk14. > > > > Can someone explain why it does not work as expected? So far I have > > not found a single example of HttpServletRequestWrapper's usage. > > > > Best regards - > > Jan Ploski > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
