Yes : it's my problem.

ctx.getContext("/myNewContext") always return a Context (even if myNewContext 
is not deployed :-(
and
ctx.getRequestDispatcher("/myNewServlet") always return a dispatcher (even if 
myNewServlet is not here :-(

So How can I avoid a 404 ?

On Wed, 02 Mar 2005 10:24:37 -0500
Tim Funk <[EMAIL PROTECTED]> wrote:

> getRequestDispatcher() will always return a servlet. (The default servlet)
> 
> -Tim
> 
> Lionel Farbos wrote:
> 
> > Hi,
> > (I work on Tomcat 5.0.30).
> > 
> > When my servlet (http://myVhost/proxy/testProxy) forward to another servlet 
> > :
> > try {
> >   ServletContext ctx = getServletContext();
> >   ctx = ctx.getContext("/myNewContext");
> >   RequestDispatcher dispatcher = ctx.getRequestDispatcher("/myNewServlet");
> >   dispatcher.forward(request, response);
> > } catch (Exception e) {e.printStackTrace();}
> > 
> > (in server.xml, in the Context /proxy of myVhost, I put crossContext="true")
> > 
> > If the Context /myNewContext is deployed in myVhost, the HTTPresponse is :
> > HTTP/1.1 200 OK
> > ...
> > response of myNewServlet
> > 
> > If the Context /myNewContext is not deployed, the HTTPresponse is :
> > HTTP/1.1 404 /myNewServlet 
> > :-(
> > 
> > 
> > 1) In other servlets containers, I read that ctx.getRequestDispatcher(...) 
> > returns null if the resource is absent.
> > So, Why Tomcat reacts differently ? Is it a bug ?
> > 
> > 2) In my case, I'd want to forward to myNewServlet if it is present, BUT, 
> > if it is absent, I'd want to call another url distant (with httpclient)...
> > How can I do this with Tomcat ?
> >  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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

Reply via email to