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

PageContext methods in EL?

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

How can I access the methods of the request interface like getMethod() and so on using EL?? One such example to access the request method in EL is like this
${pageContext.request.method}, I want to access other methods as well the same way?? How to do this??
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the pageContext object as a java bean, which means that you can call on any method that has the form getXyz() by reading the xyz property of the bean: ${pageContext.xyz}.

The same applies to the request object you can retrieve from pageContext, so then:
${pageContext.request.method}
is equivalent to:
<%= pageContext.getRequest().getMethod() %>

Note: the difference in capitalization is important.

[ March 27, 2007: Message edited by: Sergio Tridente ]
[ March 27, 2007: Message edited by: Sergio Tridente ]
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sergio,

Thanks for the reply. Like you said,

${pageContext.request.method}
is equivalent to:
<%= pageContext.getRequest().getMethod() %>

What is the way if I want to get the request url like

<%= pageContext.getRequest().getRequestURI() %> ...How can I do this usinf EL?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea guys??
 
Sergio Tridente
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jothi Shankar Kumar Sankararaj:
What is the way if I want to get the request url like

<%= pageContext.getRequest().getRequestURI() %> ...How can I do this usinf EL?



You should use: ${pageContext.request.requestURI}
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sergio,

Thank you very much for the reply. From where I can know about all the properties like this???
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jothi Shankar Kumar Sankararaj:
sergio,

What is the way if I want to get the request url like

<%= pageContext.getRequest().getRequestURI() %> ...How can I do this usinf EL?



I believe this expression should be this:

<%= ((HttpServletRequest)pageContext.getRequest()).getRequestURI() %>

(pageContext.getRequest() returns ServletRequest but its actually an HttpServletRequest)
[ March 27, 2007: Message edited by: Clifton Eaton ]
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see the API for request object...
 
Sergio Tridente
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Clifton Eaton:


I believe this expression should be this:

<%= ((HttpServletRequest)pageContext.getRequest()).getRequestURI() %>

(pageContext.getRequest() returns ServletRequest but its actually an HttpServletRequest)



You are right. Thank you.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, where can I find the rest of the properties guys?? Please let me know!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the JSP specification, there are listed at "JSP.2.2.3 Implicit Objects"
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks satou!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But Satou,

I can find only this from the specs,

${pageContext.request.requestURI} The request's URI (obtained from HttpServletRequest)
${sessionScope.profile} The session-scoped attribute named profile
(null if not found)
${param.productId} The String value of the productId
parameter, or null if not found
${paramValues.productId} The String[] containing all values of the
productId parameter, or null if not found

I want to know how we can access each method in the HttpServletRequest interface using EL?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can access all those which have a proper getter method, via pageContext.request. getRequestURI() is one, getQueryString() is another. Have look at HttpServletRequest and look for getter methods.
reply
    Bookmark Topic Watch Topic
  • New Topic