tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: static url routing
Date Sat, 07 Dec 2002 02:34:58 GMT


On Fri, 6 Dec 2002, RXZ JLo wrote:

> Date: Fri, 6 Dec 2002 01:50:31 -0800 (PST)
> From: RXZ JLo <rufoo2001@yahoo.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: RE: static url routing
>
>
> --- "Noel J. Bergman" <noel@devtech.com> wrote:
> > > my html files have long names like
> > > a_b_c_d_xyz213_e_f_g.html,
> > a_b_c_d_pqr983_e_f_g.html
> >
> > > is it possible to have urls like
> > > http://localhost:8080/myapp/html/xyz213
> > > point to the first file above?
> >
> > You can use either a Filter, or mod_rewrite in
> > Apache httpd.
> >
>
> I had a glance at javax.servlet.Filter - with this I
> cannot avoid entering a servlet, which will then wont
> be 'static' response.
>

You actually *can* avoid entering a servlet, so Filter is a very practical
way to do "redirect" type things, especially in the same webapp.

The normal flow of a Filter's doFilter() method usually looks like this:

  ... do some preprocessing ...
  chain.doFilter(request, response);
  ... do some postprocessing ...

However, there is *no* requirement that you actually call the
chain.doFilter() method to pass the request on.  It's entirely legal for
your Filter to do something that creates the response and returns, instead
of forwarding the rest of the call.

To do a redirect filter, then, you'd examine the request URI to determine
what kind of remapping is needed, and then do a
RequestDispatcher.forward() call to the remapped resource name.  After the
forward returns (which means that the actual response has been created),
simply return instead of calling chain.doFilter() to pass the request on.

>
> > 	--- Noel
> >
>
> Thanks
> rf
>

Craig



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message