Win a copy of Terraform in Action this week in the Cloud 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Doubt in PageContext

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is the following two are line are same ?

pageContext.request.method

pageContext.getRrequest().getMethod()

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
provided request and method are the objects obtained from getRequest() and getMethod() resp.

Correct me if I am wrong..

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not really, they are not the same.

${pageContext.request.method} would be the same as pageContext.getRequest().getMethod(); but both of them would cause compile time error in a jsp provided request is an instance of an implementation of javax.servlet.HttpServletRequest given that method is not really a method defined in that interface.
 
Sheriff
Posts: 22512
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpServletRequest.getMethod() does exist.
 
cesar valencia
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh yeah, that's right! Sorry, it eluded me as being "any given method" instead of a real method (get http method), otherwise my statement remains correct.
 
Abhijit Das
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i missed out one thing. These are used in EL.

${pageContext.request.method}

${pageContext.getRequest().getMethod()}
 
Greenhorn
Posts: 5
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
${pageContext.request.method} will be correct in JSTL. But if you use expression language you should not use the method call, ${pageContext.request.method} will evaluate to pageContext.getRequest().<getMethod>(). [Replace <getMethod> by real method name]
As noted in previous posts, getMethod is not valid for javax.servlet.HttpServletRequest.
 
Rob Spoor
Sheriff
Posts: 22512
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Finny Samuel wrote:As noted in previous posts, getMethod is not valid for javax.servlet.HttpServletRequest.


As noted in previous posts, yes it is.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic