You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Arieh Markel <Ar...@central.sun.com> on 2000/08/18 20:17:40 UTC

Is there an easier way (was: changes from 3.1 to 3.2)

Thanks to Costin for the reponse.

Reading the doc and the code, I realized that one of the ways to execute
what I was trying to do (accept a request, and force a redirection to
a /login servlet on a different context than the one that was originally
requested) is as follows:

	//  get the 'console' context, from which the /login servlet is
	//  invoked. (class invoked is one I developed for our application)
	//
        Context sc = ServerUtils.getConsoleContext ();

	//  get the ServletWrapper that matches the /login servlet, in order
	//  to get to its respective RequestDispatcher
	//
        ServletWrapper s = (ServletWrapper) sc.getServletByName (
                                    Constants.Context.Console.Components.Login);

	//  get the RequestDispatcher associated with the /login servlet
	//
        RequestDispatcher rd =
    s.getServlet().getServletConfig().getServletContext().getNamedDispatcher(
                                    Constants.Context.Console.Components.Login);

        rd.forward (req, res);
        
        
I was wondering if there was a more straightforward way to evaluate the
RequestDispatcher than the one I figured out.

Thanks,

Arieh
--
 Arieh Markel		                Sun Microsystems Inc.
 Network Storage                        500 Eldorado Blvd. MS UBRM11-194
 e-mail: arieh.markel@sun.COM           Broomfield, CO 80021
 Let's go Panthers !!!!                 Phone: (303) 272-8547 x78547
 (e-mail me with subject SEND PUBLIC KEY to get public key)


Re: Is there an easier way (was: changes from 3.1 to 3.2)

Posted by cm...@yahoo.com.
What about: 

ServletContext sctx= getServletContext();
ServletContext targetCtx=sctx.getContext( "/login" );
RequestDispatcher rd=targetCtx.getNRD (... ); 

Costin

> 	//  get the 'console' context, from which the /login servlet is
> 	//  invoked. (class invoked is one I developed for our application)
> 	//
>         Context sc = ServerUtils.getConsoleContext ();
> 
> 	//  get the ServletWrapper that matches the /login servlet, in order
> 	//  to get to its respective RequestDispatcher
> 	//
>         ServletWrapper s = (ServletWrapper) sc.getServletByName (
>                                     Constants.Context.Console.Components.Login);
> 
> 	//  get the RequestDispatcher associated with the /login servlet
> 	//
>         RequestDispatcher rd =
>     s.getServlet().getServletConfig().getServletContext().getNamedDispatcher(
>                                     Constants.Context.Console.Components.Login);
> 
>         rd.forward (req, res);
>         
>         
> I was wondering if there was a more straightforward way to evaluate the
> RequestDispatcher than the one I figured out.
> 
> Thanks,
> 
> Arieh
> --
>  Arieh Markel		                Sun Microsystems Inc.
>  Network Storage                        500 Eldorado Blvd. MS UBRM11-194
>  e-mail: arieh.markel@sun.COM           Broomfield, CO 80021
>  Let's go Panthers !!!!                 Phone: (303) 272-8547 x78547
>  (e-mail me with subject SEND PUBLIC KEY to get public key)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>