Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

setting attributes in the scopes  RSS feed

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we set primitive's(say int Array) into the Attributes??

ex:
<%
int[] ia = { 10, 110, 1110 };
request.setAttribute("ia", ia);
%>
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can. Because an int[] is also an object and not a primitive.
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I replace it to only int/float?
 
Pavan Sambare
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will not be able to set only int/float as the setAttribute method's signature is request.setAttribute(String, Object). You would need to set them as Wrappers.
 
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so because we can set primitive on setAttribute method.
I did myself without any headache.

best regards,
omi
 
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I don't think so because we can set primitive on setAttribute method.[/QB]

That's because your JRE runtime is version 5 or later - so it's using auto-boxing to automatically wrap the primitive into its associated wrapper, and un-box it again as required... it's still storing an object!
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Array is an object.
so we can setAttribute of request,session,context.For the code session scope doesn't make any sense but since array is object you can set Attribute for any scope.

Sravanthi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!