Chuck,

Thank you again for your help.  Since I'm new at this, please forgive me if
my questions seem elementary.  The following code now works:

ServletContext appContext = getServletContext().getContext( "/dev" );

      if ( appContext != null )
      {
         RequestDispatcher rd = appContext.getRequestDispatcher(
"/jsp/index.jsp" );
         rd.forward( request, response );
      }

If I understand the above correctly, the ServletContext sets the new
<Context> to /dev and the RequestDispatcher appends "/jsp/index.jsp" to the
new path.  The complete path should be /dev/jsp/index.jsp.  Correct?

Unfortunately, I get a blank page in my browser and the page properties show
/filter/jsp/index.jsp which is the original <Context> path.  Am I still
doing something wrong?  I've been reading the Servlet API, but I don't
understand how the pathing resolves.  I also removed the crossContext="true"
from the new target <Context>.

If I change the following to:

RequestDispatcher rd = appContext.getRequestDispatcher( "/dev/jsp/index.jsp"
);

the browser trys to render /dev/dev/jsp/index.jsp.

Thanks for your patience,

Brandon

Hassan Schroeder-2 wrote:
> 
> On Sun, Mar 29, 2009 at 5:52 PM, Caldarale, Charles R
> <chuck.caldar...@unisys.com> wrote:
> 
>>> ServletContext appContext =
>>> this.getServletConfig().getServletContext().getContext( "/dev" );
>>
>> You certainly don't need "this" in the above; nor is getServletConfig()
>> necessary, if the code is in a class that extends HttpServlet.  Doing so
>> just adds unnecessary overhead.
> 
> Absolutely correct -- serves me right for grabbing something out of a
> bucket full of ancient experiments.
> 
> I should cut down on the context switching between ruby/rails/rspec
> and java/servlets -- getting a slight case of whiplash  :-)
> 
> Thanks for setting that straight!
> 
> -- 
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Forwarding-from-one-Context-to-another-tp22767662p22775380.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to