I currently have a security filter servlet which checks for a valid
session and then in most cases forwards it's request to a FileServlet to
serve the originally requested file.

   Presently I use ServletContext.getServlet() to get to the file servlet.
As this is generally considered to be a BAD THING, I am trying to switch to
the new RequestDispatcher interface.

   My problem is that both the forward() and include() methods of
RequestDispatcher seem to clobber the URL in the request and instead pass
the path of the target servlet.

  The following servlet demonstrates my problem:

=========
import javax.servlet.*;
import javax.servlet.http.*;

public class DispatchTest extends HttpServlet {

public void service(HttpServletRequest req, HttpServletResponse res)
   throws ServletException, java.io.IOException {

   ServletContext sc = getServletConfig().getServletContext();
   RequestDispatcher rd = sc.getRequestDispatcher("/servlet/SnoopServlet");
   rd.include(req, res);
   //rd.forward(req, res);
   }
}
==========

   The 2.1 servlet docs say that:

for forward():

   "The request object passed to the target object will have its request URL
path and other path parameters adjusted to reflect the target URL path of
the target object. "

for include():

"The request object passed to the target object will reflect the request URL
path and path info of the calling request.".

   I'm getting the same behavior from both JRun 2.3 and the JSDK 1.2 Early
Access release. Both include() and forward() invoke SnoopServlet with a
request path of /servlet/SnoopServlet.

   Either I'm doing something wrong or there is a bug in include() such that
it is modifying the paths as per forward().

  Perhaps something is happening in the invoker servlet that I'm not aware
of? Any help would be appreciated.

Doug Harris
Product Architect,
FreeBalance Inc.
http://www.FreeBalance.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to