You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by James Cook <ji...@iname.com> on 2000/01/31 04:51:02 UTC

Error using RequestDispatcher?

Please tell me if this is not the appropriate forum for this question.

I am using the RequestDispatcher to invoke other servlets from my main
servlet. Everything seems to work fine for now, however I get the following
test returned in my HTML:

Included servlet error: 404: No detailed message

Any clues as to what this means? My included servlet presents the
appropriate output, however this message is tacked on.

Also, what is the appropriate use of the out.close() & out.flush() when
chaining servlets? I am using stream methods in the following manner:

	Servlet#1:	out = request.getOutputStream();
	Servlet#1:	out.println(some html)
	Servlet#1:	out.flush();

	Servlet#1:	ServletContext context = getServletContext();
	Servlet#1:	RequestDispatcher rd = context.getRequestDispatcher(Servlet#2);
	Servlet#1:	rd.include(request, response);

		Servlet#2:	out = request.getOutputStream();
		Servlet#2:	out.println(some html)
		Servlet#2:	out.flush();

	Servlet#1:	out.println(some html)
	Servlet#1:	out.close()

This is the only combination that I found to work, however it goes against
the Sun tutorial on the subject. I find it odd that Servlet#2 cannot call
out.close(). What if it is called directly by the servlet engine? It
wouldn't issue a close() and output would not be returned to the client?

Use of out.flush() is not shown anywhere in any tutorials, however if I
didn't use it in the second servlet, the output from that servlet was not
visible. Is there a best practice for this?

thanks,
jim