-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chinmay,

I checked the source, and this is what we've got:

    public MessageBytes setValue( String name ) {
        for ( int i = 0; i < count; i++ ) {
            if(headers[i].getName().equalsIgnoreCase(name)) { // 267
                for ( int j=i+1; j < count; j++ ) {
                    if(headers[j].getName().equalsIgnoreCase(name)) {
                        removeHeader(j--);
                    }
                }
                return headers[i].getValue();
            }
        }
        MimeHeaderField mh = createHeader();
        mh.getName().setString(name);
        return mh.getValue();
    }

The indicated line number is line 267, where your exception is
occurring. So, the problem is either that the headers array is null, or
the name of your header is null.

I tried another JSP, and this failed differently:

<%
 response.setHeader(null, "foo");
%>

Fails here:
> java.lang.NullPointerException
>         at org.apache.coyote.Response.setHeader(Response.java:325)
>         at 
> org.apache.catalina.connector.Response.setHeader(Response.java:1339)
>         at 
> org.apache.catalina.connector.ResponseFacade.setHeader(ResponseFacade
> .java:480)
>         at 
> org.apache.jsp.admin.HeaderTest_jsp._jspService(HeaderTest_jsp.java:56)

So, it's not a problem with your header name or value, so I guess the
response header array is being blanked-out. I don't see a place where
the 'headers' member could ever be null: it is set in the constructor
and in the createHeader method when it needs to be expanded, but never
nulled-out.

'headers' is MimeHeaderField[] and MimeHeaders.recycle calls recycle on
all the headers in the array. MimeHeaderField contains two MessageBytes
buffers and calls recycle on those when it gets recycled, then nulls-out
the "next" reference (though 'prev' and 'next' appear never to be used
for anything), but the 'nameB' member should stay non-null.

So, the code says that one of those references ('headers' or
'headers[i].getName()' which is MimeHeaderField.nameB) is null, but I
don't see how either of them could be null. I'm at a loss, here.

One thing is for sure: this is not a good sign at the top of
MimeHeaders.java:

/* XXX XXX XXX Need a major rewrite  !!!!
 */

References:
http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_20/java/org/apache/tomcat/util/http/MimeHeaders.java

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt+vOQACgkQ9CaO5/Lv0PAfjwCfQ9gTSOyB4UG337tqD6S5EvEq
OWEAmwYNrXgzdst6ix1z4n5slSijpblb
=Wt1g
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to