org.apache.tomcat.sendfile.support attribute returned via getAttribute() but name not returned via getAttributeNames() Jun 5 (8 days ago) Chris Markle to users Hi, Probably missing something simple here but I can't figure it out... I have pretty much just modified a simpel hello world servlet as I start to play around with NIO sendfile support. I am using Tomcat 6.0.20. I am trying to check for the org.apache.tomcat.sendfile.support which says I can use the sendfile mode. When I request the request atttributes in the doPut method via getAttributeNames(), I seem to get back an Enumeration with no attribute names in it. None... But when I ask for the org.apache.tomcat.sendfile.support attribute specifically via getAttribute(), I do get the attribute and it is correctly set to Boolean true/false depending on whether I've configured NIO in server.xml. Here is my code: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Enumeration attrNames = request.getAttributeNames(); if (attrNames == null) { System.out.println("getAttributeNames returned null"); } else { System.out.println("attrNames: " + attrNames.toString()); } System.out.println("printing any attrs..."); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); System.out.println("attr: " + attrName); } Boolean val = (Boolean) request.getAttribute("org.apache.tomcat.sendfile.support"); if (val != null) { System.out.println("org.apache.tomcat.sendfile.support attr found: value: " + val.toString()); } else { System.out.println("org.apache.tomcat.sendfile.support attr not found"); } response.getWriter().write("Hello, world!"); } Thanks in advance for any help on this... Chris * * * Jun 8 (4 days ago) Chris Markle to users Folks, Going to try this again since I got no reply to my first inquiry. I'd like to log a bug report along the lines of "request getAttributeNames method does not return all request attributes (e.g., org.apache.tomcat.sendfile.support)". Either that or this is a doc issues somewhere. I know in the scheme of things this is not an earth-shattering issue / bug, still it's apparently not working correctly. I would put this one of two ways, either: 1. The Tomcat HttpRequest getAttributeNames method has a bug and doesn't return the attribute like org.apache.tomcat.sendfile.support (even though I can access that attribute via the getAttribute method); or 2. There's a doc error in the getAttributeNames doc where the cases where it doesn't show all attribute names needs to be explained. Thanks! Chris * * * Jun 9 (4 days ago) Rainer Jung to Tomcat On 08.06.2009 22:15, Chris Markle wrote: > Folks, > > Going to try this again since I got no reply to my first inquiry. I'd > like to log a bug report along the lines of "request getAttributeNames > method does not return all request attributes (e.g., > org.apache.tomcat.sendfile.support)". Either that or this is a doc > issues somewhere. I know in the scheme of things this is not an > earth-shattering issue / bug, still it's apparently not working > correctly. > > I would put this one of two ways, either: > > 1. The Tomcat HttpRequest getAttributeNames method has a bug and > doesn't return the attribute like org.apache.tomcat.sendfile.support > (even though I can access that attribute via the getAttribute method); > or > > 2. There's a doc error in the getAttributeNames doc where the cases > where it doesn't show all attribute names needs to be explained. > > My original message on the topic is below. Yes, there are request attributes, that you can retrieve via getAttribute(), but are not visible in getAttributeNames(). Those are mostly somehow connector internal attributes, but yes, some of them can be interesting to use in a webapp. Unfortunately this will not be easy to fix, but you should add an issue to Bugzilla. Regards, Rainer * * * Chris Markle to Tomcat Ranier, > Yes, there are request attributes, that you can retrieve via > getAttribute(), but are not visible in getAttributeNames(). Those are > mostly somehow connector internal attributes, but yes, some of them can > be interesting to use in a webapp. Unfortunately this will not be easy to > fix, but you should add an issue to Bugzilla. Thanks for the reply. I'll log something in Bugzilla per your request. Chris