> Could somebody tell me if this behavior by design and if so why:
> 
> The following fragment forwards a request to main application page:
> 
> //-----------------------
> String main = "/index.jsp";
> //String main = "/";
> 
> RequestDispatcher dispatcher
>     = getServletContext().getRequestDispatcher(main);
> dispatcher.forward(req, resp);
> //-----------------------
> 
> 
> Forwarding works on server side if code being executed as shown (main is
> "/index.jsp") so client isn't aware about it. However, if main is set to be
> "/" (commented line above), 302 is sent to the client, so it's not a
> server-side redirect, right? In this case response "Location" header is set
> to http://host/pathtowebapp/index.jsp. Am I missing something? Tomcat was
> able to find out that index.jsp is a welcome file but nonetheless it's a
> client side redirect. Not a big problem of course, just curious...

You have to be clear about what you mean when you say "forward".
There is "send a redirect" or "get a RequestDispatcher", which are
different things.  What the fragment above does is it tries to forward
to a servlet which is the resources associated with /.  That doesn't
exist so it sends an error.  If you want to send something to the
client you need to use response.sendRedirect() I believe.

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to