• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL doubt?

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, in the following code how do we get the o/p EL in either syntax? What happens in the background when we hit the EL and how the o/p is evaluated?

<html>
<head><title>As a normal JSP</title></head>
<body>
<% request.setAttribute("whichever", "EL in either syntax"); %>
<p>${whichever}</p>
</body></html>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This expression will look for the attribute named whichever, searching the page, request, session, and application scopes, and will return its value. If the attribute is not found, null is returned.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it will do a pageContext.findAttribute(). Now what if I'm not trying to display any attribute but rather just a text?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a container provider, but I'd say that it looks for a String and just prints it.

String -With single and double quotes - " is escaped as \", ' is escaped as \', and \ is escaped as \\. Quotes only need to be escaped in a string value enclosed in the same type of quote
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic