I know this probably isn't the correct place to ask this, but I reckon you
guys are probably the most qualified to answer it:

Am I allowed to include and forward between servlet contexts?

i.e. Am I allowed to write a method like this:

private void include(ServletRequest request, ServletResponse response, 
                     String contextPath, String relativePath)
throws ServletException, IOException
{
    ServletContext context = getServletContext().getContext(contextPath);
    RequestDispatcher requestDispatcher =
        context.getRequestDispatcher(relativePath);
    requestDispatcher.include(request, response);
}

Because it kind of works. Though if I don't flush() first, things get kind
of screwed up.

If I am allowed to do this, what should I expect to get if I do stuff like
getServletContext() in the included servlet? It seems that I get the context
of the original servlet, not the included one. Which isn't very useful to
me.

If I'm _not_ allowed to do this, can someone please tell me so that I can
start looking for a different way to do this?

Cheers.

Reply via email to