• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about EL pageContext implicit object

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, on page 384 of HF it is said that, in order to retrieve the request method through EL (the equivalent of HttpServletRequest.getMethod()), it
is possible to use the following expression:

${pageContext.request.method}

Earlier in the book it is said that 'pageContext' is of type PageContext. I'm looking at the interface, and although it has got a getRequest method in it, the returned type is ServletRequest and not HttpServletRequest. The getMethod() method is not available to the ServletRequest interface, as this is an HTTP specific feature.

Am i wrong?

Thanks for your attention,

Marco
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you see the javax.servlet.jsp.JspFactory abstract class there is a getPageContext method with the following signature

getPageContext(javax.servlet.Servlet servlet,javax.servlet.ServletRequest request,ServletResponse response,String errorPageURL,boolean needsSession,
int buffer,boolean autoflush)

The request object passed is the <b>current request pending on the servlet<b> and since you are dealing with Http request the getMethod works correctly.

Hope that helps.


Sawan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic