• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Request Parameter -Regarding

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mock exam Question:
${request.noise} #1
${param.noise} #2
${requestScope.noise}#3
What will happen when the page is compiled and executed with the query string

index.jsp?noise=moo

What is the Output and which one will work.
 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
output is #1 moo #2 #3
${param.noise} will execute.
 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


"noise" in this case is a request attribute and not a parameter. Therefore, the output of ${requestScope.noise} is nothing. This is because "noise" as a parameter is not defined.

Please let me know if I am correct?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Firas,
The line: index.jsp?noise=moo
indicates that index.jsp is being invoked with a parameter whose name is "noise" and value is "moo".
Now this parameter value can be retrieved in the index.jsp page by using the EL expression ${param.noise}. Note that "param" is the implicit EL variable that is used to retieve the value of parameter being sent to the jsp.

${requestScope.noise} refers to the value of attribute object named "noise" that is added to the request scope(request.setAttribute(String name,Object obj)) and is retrievable using the implicit EL variable "requestScope".

The expression ${request.noise} is invalid since there is no implicit EL variable named "request".

Hence the answer is: #1 moo #2 #3
Note that "noise" is a parameter not a request attribute.

Hope this is clear


Stay connected, Remain beautiful,
Abhijeet
SCJP 1.4, SCWCD 1.4

[ December 18, 2006: Message edited by: Abhijeet Mahule ]
[ December 18, 2006: Message edited by: Abhijeet Mahule ]
 
Firas Zuriekat
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, this clears many things. If one could remember that EL almost never throws an Exception or Error (it's very forgiving), then the output here will be nothing when ${request.noise} is used (request doesn't exist in EL).

So that's why we get this result even when using this non-existent "request".



EL is cool
[ December 18, 2006: Message edited by: Firas Zuriekat ]
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
good revision for me
 
Tell me how it all turns out. Here is a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic