Perhaps you should send the code to which you call HttpServletRequest.setAttribute() .
At the moment, it seems that your cruel and poorly serviced servlet removes the attributes between your two getAttributeNames() calls, but without any code examples that are hard to say.
UPDATE
Nothing in the code jumps at me as a fault ... so I created a very simple test script inside handleRequest() and gave it a twist (using jboss-eap-4.3 as my container). At first I had to manually set the attribute, since I understand the request attributes, they are always set on the server side (i.e. if I did not set it, then I did not get any output, since the Enumeration returned by getAttributeNames() was empty).
request.setAttribute("muckingwattrs", "Strange"); Enumeration attrs = request.getAttributeNames(); while(attrs.hasMoreElements()) { System.out.println(attrs.nextElement()); } System.out.println("----------------------------"); Enumeration attrs2 = request.getAttributeNames(); while(attrs2.hasMoreElements()) { System.out.println(attrs2.nextElement()); }
Exit
INFO [STDOUT] muckingwattrs INFO [STDOUT] ---------------------------- INFO [STDOUT] muckingwattrs
So, maybe your container does not implement getAttributeNames() correctly? Perhaps try a very simple test case, for example directly in handleRequest() or doGet()/doPost() .
source share