tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <da_alchem...@yahoo.com>
Subject How do I change servlet contexts???
Date Wed, 30 Jul 2003 22:55:53 GMT
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


Mime
View raw message