You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by BugRat Mail System <to...@cortexity.com> on 2000/09/05 12:59:57 UTC

BugRat Report #68 has been filed.

Bug report #68 has just been filed.

You can view the report at the following URL:

   <http://znutar.cortexity.com:8888/BugRatViewer/ShowReport/68>

REPORT #68 Details.

Project: Tomcat
Category: Bug Report
SubCategory: New Bug Report
Class: swbug
State: received
Priority: high
Severity: critical
Confidence: public
Environment: 
   Release: 3.2 beta 3
   JVM Release: 1.2
   Operating System: Windows
   OS Release: 98
   Platform: PC

Synopsis: 
request.getSession() fails when followed by RequestDispatcher.include()

Description:
The following example is a servlet which opens a session, and then :
1- does nothing
2- include a JSP
3- forward to a JSP

cases 1 and 3 work fine : a JSESSIONID cookie is set, and the session context is retrieved
properly on the next requests.
Case 2 fails : the JSESSIONID cookie is not set. And a new session context is created at each request.

BUG ANALYSIS : 
--------------

With a debugger, one can see that the SessionInterceptor::beforeBody() method is not called in the
case 2 (include), but it is called in the other cases. (it is the method which create the JSESSIONID cookie).

It seems that the bug comes in the following method : HttpResponseAdapter.notifyEndHeaders(). 
The last test is false in the case of the JSP include. So the
doBeforeBody is not called. This is not good since the servlet should be capable to work on HTTP headers, open session,...
before it includes a JSP.


/** Signal that we're done with the headers, and body will follow.
 *  Any implementation needs to notify ContextManager, to allow
 *  interceptors to fix headers.
 */
   public void notifyEndHeaders() throws IOException {
	   //	System.out.println("End headers " + request.getProtocol());
	   if (request.getProtocol() == null)
	   	// HTTP/0.9 
	   	return;

	   // let CM notify interceptors and give a chance to fix
	   // the headers
BUG >>>	   if (request.getContext() != null && notIncluded)
	 	request.getContext().getContextManager().doBeforeBody(request, this);

	   // No action.. 
   }