On Fri, 13 Dec 2002, RXZ JLo wrote:

> Date: Fri, 13 Dec 2002 05:31:12 -0800 (PST)
> From: RXZ JLo <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: RE: RequestDispatcher scenarios ( was RE: static url routing)
>
>
> --- "Cox, Charlie" <[EMAIL PROTECTED]> wrote:
> > RequestDisatcher is for dispatching (parts of)the
> > current request to other
> > resources in the same context without involving the
> > browser. This means that
> > it is not a new request(filters/valves/etc do not
> > get invoked), but it is
> > processed by the servlet/filter just like a request
> > directly to the
> > servlet/filter
> >
>
>
> Lets say in my servlet I modify the HttpServletRequest
> changing the url to a statically accessible file, and
> pass it on to RequestDispatcher.forward. Now, does the
> DefaultServlet handle the static file?

Assume that the input request URI is "/index.html" and you want to
redirect to "/index.html.fr" for French users and "/index.html.es" for
Spanish users (based on the Accept-Language header).  In order to do this,
you wouldn't actually modify the passed-in request -- instead, you would
specify the modifed path when you ask for a request dispatcher.  Something
like this:

  Locale locale = ... user's requested locale ...
  String requested = ... originally requested path (context relative) ...
  String revised = requested + "." + locale.getLanguage();
  RequestDispatcher rd =
   getServletContext().getRequestDispatcher(revised);
  rd.forward(request, response);
  return;

If the static resources "/index.html.fr" and "/index.html.es" exist in
your webapp, that's all you need to do -- presumably these URLs won't be
mapped to anything else, so the default file-serving servlet will be
selected by the request dispatcher, and will be used by the forward()
call.

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to