• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EL and Accessing request scope attributes

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If you have HFJS:

HFJS page 398 Chap 8,
How come in most of the print statements the author has used directly the attribute name without using the 'requestScope' accessor?

If you dont have the book:

Servlet code:
String num="2";
request.setAttribute("num",num);
Integer i=new Integer(3);
request.setAttribute("integer",i);

Q is what will they print:
1) ${num>3)
2)${integer le 12}
3)${requestScope["integer'] ne 4 and 6 le num || false}

Now how come in the 3) we are accessing the attributes using 'requestScope' and in other places they are being direclty accessed?

 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Amarkirt. In ${num>3}, the container first chooses the 'num' attribute in the page scope, if it finds, it will compare with 3. If it not find, then chooses in the request scope, here(in this example) we can have, and compares with 3. If it didn't find, then chooses, Session and Application Scopes(Here the order is important, page->request->session->application scopes).


In ${requestScope["integer"], container only sees in the request scope.
 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic