You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Markle <cm...@comcast.net> on 2009/06/05 10:05:41 UTC

org.apache.tomcat.sendfile.support attribute returned via getAttribute() but name not returned via getAttributeNames()

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<String> 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

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


Re: org.apache.tomcat.sendfile.support attribute returned via getAttribute() but name not returned via getAttributeNames()

Posted by Chris Markle <cm...@comcast.net>.
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

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


Re: org.apache.tomcat.sendfile.support attribute returned via getAttribute() but name not returned via getAttributeNames()

Posted by Rainer Jung <ra...@kippdata.de>.
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

> On Fri, Jun 5, 2009 at 1:05 AM, Chris Markle<cm...@comcast.net> wrote:
>> Hi,
>>
>> Probably missing something simple here but I can't figure it out... I
>> have pretty much just modified a simple 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
>> attributes 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<String> 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

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


Re: org.apache.tomcat.sendfile.support attribute returned via getAttribute() but name not returned via getAttributeNames()

Posted by Chris Markle <cm...@comcast.net>.
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.

Thanks!

Chris

On Fri, Jun 5, 2009 at 1:05 AM, Chris Markle<cm...@comcast.net> wrote:
> Hi,
>
> Probably missing something simple here but I can't figure it out... I
> have pretty much just modified a simple 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
> attributes 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<String> 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

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