• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL and Accessing request scope attributes

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • 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?

 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic