tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: How do I change servlet contexts???
Date Thu, 31 Jul 2003 13:31:18 GMT

Why not just do
RequestDispatcher rd =

I.e. don't have the explicit getContext("/example") call in the middle
as you're already in that context.

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: []
>Sent: Wednesday, July 30, 2003 6:56 PM
>Subject: How do I change servlet contexts???
>Tomcat: 4.1.24
>I have a war file whose base context is "/example".
>Within that context there is an HTTP servlet
>(GuestServlet) with a servlet mapping that captures
>everything under "/example/guest/*".  Within
>GuestServlet.class I create a RequestDispatcher to
>forward control to an HTML page (lookup.html) under
>the base context (/example).  The problem is when
>control is forwarded to /example/lookup.html it does
>not work.  The context remains unchanged at
>/example/guest and so it actually attempts to display
>/example/guest/lookup.html when I need
>/example/lookup.html.  I use the following code within
> to try and display lookup.html under
>the base context /example.  Will someone please tell
>me what I am doing wrong?
>public class GuestServlet extends HttpServlet {
>  protected void doPost(HttpServletRequest request,
>HttpServletResponse response) throws ServletException,
>IOException {
>    RequestDispatcher rd = null;
>    // Dispatch to next url
>    ServletContext cntxt =
>    rd = cntxt.getRequestDispatcher("/lookup.html");
>    rd.forward(request, response);
>  }
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message