RE: How do I change servlet contexts???

2003-07-31 Thread Shapira, Yoav

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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 6:56 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How do I change servlet contexts???

2003-07-30 Thread da_alchemist
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]