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 15:03:13 UTC

edit bug #21 by person #0 (logged in as: Nick Bauman)

Bug description modified:
   Description changed from:
    > 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.. 
   } 




   To:
    > The following example is a servlet which opens a session, and then :
<br>
1- does nothing
<br>
2- include a JSP
<br>
3- forward to a JSP
<p>
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.
</p>
<p>
BUG ANALYSIS : 
--------------
</p>
<p>
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).
</p>
<p>
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.
</p>

<pre>
/** 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.. 
   } 
</pre>



Reproduce description modified:
   Description changed from:
    > 
   To:
    > <p>
BUG SAMPLE CODE :
-----------------
</p>
<p>
To run the sample below, use the following URLS : 
<br>
1- http://hostname/webapppath/serv1
<br>
2- http://hostname/webapppath/serv1?cmd=include
<br>
3- http://hostname/webapppath/serv1?cmd=forward
<p>


package test;

impor

Work around description modified:
   Description changed from:
    > 
   To:
    > None