Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EL doubt

 
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.
 
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just add in your code <%@ page isELIgnored="false" %>
it will work.
 
vijay kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have used ,i am getting an error

Parsing of JSP File '/EL_Variables.jsp' failed:
--------------------------------------------------------------------------------
/EL_Variables.jsp(2): unrecognized JSP directive: 'isELIgnored'='false'
probably occurred due to an error in /EL_Variables.jsp line 2:
<%@ page isELIgnored="false" %>

in web xml also i added the
<el-enabled>true</el-enabled>

tag but its not reflecting
 
carina caoor
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way whats there in EL_VARIABLES.jsp?
 
vijay kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is simple jsp

code:
<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>

still i am not able to enable the EL's
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very strange that your EL expressions are treated as template text only after you submit your form. I would expect them to be treated as such always or never, but not "sometimes".

Anyway, I can see what you are trying to do and it will not work. You have declared a field in your JSP-page (or the servlet that is generated from your JSP page) and you want to retrieve its value in an EL expression. EL however requires variables that are attributes of one of the four scopes: page, request, session or context.

Also, it is usually not a good idea to use servlet instance variables, as they can be accessed and changed by multiple clients.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic