tomcat-users mailing list archives

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

Howdy,
Why not just do
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/lookup.html");

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: da_alchemist@yahoo.com [mailto:da_alchemist@yahoo.com]
>Sent: Wednesday, July 30, 2003 6:56 PM
>To: tomcat-user@jakarta.apache.org
>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
>GuestServlet.java 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 =
>context.getContext("/example");
>    rd = cntxt.getRequestDispatcher("/lookup.html");
>    rd.forward(request, response);
>...
>  }
>...
>}
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message