Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on EL

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Why ${request.method} does not work?
With regards,
Padma priya N.G.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In HFSJ, it is told that there is no implicit request object and it works in the following manner:

${pageContext.request.method}


I am told in the book that it is essential to use requestScope to get request attributes and for request properties, use pageContext.

Can you elaborate on this as to why they only should be used ?
With regards,
Padma priya N.G.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have four implicit objects of different scope.
pageScope
requestScope
sessionScope
application

These four are Map, comprising key and object.

To access the properties of the scope we need to go through pageContext (not
a Map) implicit object.

[priya]I am told in the book that it is essential to use requestScope to get request attributes and for request properties, use pageContext.
Can you elaborate on this as to why they only should be used ?


You think, if you had to handle attributes and properties together
on a single implicit object, would it be feasible to do.


Thanks,
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandra,
To access the session object, is this is the right call?

${pageContext.session.method}

With regards,
Padma priya N.G.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. It should be



Just refer the Implicit Variable's name. They are of course case sensitive!

HtH.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have answered to your another query asking the difference between Implicit Objects Vs Implicit Variables in this thread .

There i have listed all the implicit objects and variables (for a quick reference).

HtH.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raghavan,
It is not {pageContext.requestScope.method} and it is {pageContext.request.method}

With regards,
Padma priya N.G.
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Priya,

You are right, we can have only one of these
${pageContext.out}
${pageContext.request}
${pageContext.servlet}
${pageContext.application}

to get respective scope objects

There are nothing like
${pageContext.requestScope}
${pageContext.servletScope}
${pageContext.applicationScope}


Except pageContext implicit object, all other implicit objects are maps. Not the actual objects. Please keep this in mind.

Regards,
Khushhal
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally quoted by padmapriyagururajan priya :

Hi Raghavan,
It is not {pageContext.requestScope.method} and it is {pageContext.request.method}


Priya,

What i had mentioned was for 'sessionScope' and NOT requestScope.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have four implicit objects of different scope.
pageScope
requestScope
sessionScope
application

These four are Map, comprising key and object. These Maps allow you to retrieve the attributes that were set into them. Say you had a Customer object and in a servlet you set it into the request (request.setAttribute("cust",new Customer());

You could not retrieve a request parameter that was set when you posted a name/value pair using the requestScope. WHY? because the requestScope object is not the request object itself, it is a Map of the attributes that are set into the real request object. For this same reason, you cannot get to a property of the real request object using the requestScope implicit object. YOu can get a handle to the real request object using pageContext.request.xxx where xxx is a property of the real request object. This is because the pageContext is a reference to the PageContext object

By the way, if you want to access the posted request parameters, you can use the EL implicit object called param which is a MAP of the request parameters
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic