Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL doubt

 
vijay kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have a problem with EL.i tried this program

<html><body>
<b>Expression Language Variables</b>
<%! int x=4; %>
<p>The script expression for x = <%= x %>.
<p>The EL expression for x = ${x}.
<form action="EL_Variables.jsp" method="GET">
<p>What is x? <input type="text" size=2 name="num">
<p><input type="submit">
</form>
<p>That's ${param.num == 4}!
</body></html>

and i am expecting output in this way

Expression Language Variables
The script expression for x = 4.

The EL expression for x =

What is x?



That's true

if i pass x=4

but i am getting output as

Expression Language Variables
The script expression for x = 4.

The EL expression for x = ${x}.

What is x?



That's ${param.num == 4}!

Please help me ....
Thanks in advance....
Regards,
Vijay.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think EL is not enabled.

Check which kind of JSP you're using. You need to use JSP 2.0 or higher for EL. You can check this in the web.xml

Servlet 2.3 > JSP 1.2
Servlet 2.4 > JSP 2.0
 
carina caoor
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even i tried the same program and i got the result as .........

Expression Language Variables
The script expression for x = 4.

The EL expression for x =.

What is x?



That's true!


its evaluating the ${param.x==4} part,where i am passing the value in the text field and param.num is resolving to that value i entered but its not printing the value of x (at second line) declared .Does EL have any restrictions of such kind?
 
Sandeep Krish
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EL expression for x = ${x}. is trying to access a scripting variable. EL cannot access scrpting variables.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic