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

EL pagecontext

 
marco borsato
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is printed here:

request.setAttribute("pageContext", "pagecontext");

${pageContext}

This is supposed to be legal compiled code with no exceptions thrown (if no typos made). The problem is setting the implicit object pageContext as attribute. What is printed and why?

Thanks.
 
Leandro Sales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did what you ask and got this:


org.apache.jasper.runtime.PageContextImpl@18eb7e0

I think is the default toString() from Object...

Remember, it is not recommend to use implicit variable names to reference scope attributes
 
Sujith V T
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marco

request.setAttribute("pageContext", "pagecontext");
${pageContext}

This is supposed to be legal compiled code with no exceptions thrown (if no typos made).

Yes the code is legal.



The problem is setting the implicit object pageContext as attribute.

No, You have not set the implicit object pageContext as attribute. What u have set is a String "pageContext".
To set the implicit object pageContext
change -----> request.setAttribute("pageContext", "pagecontext");
To -----> request.setAttribute("pageContext", pagecontext);

What is printed and why?
When u write ${pageContext} u are getting the toString() of implicit pageContext object.
${requestScope["pageContext"]} might give u the output u expected. If that is what u are looking for...


Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic