How to use EL in JSP
Hi,
I am trying to use EL in JSP,as EL syntax is ${first.secondvalue},but whenever i write this in my program and i run it,it is showing like this only not the value which it has to show.
I think that EL is not being enabled in my jsp.
I write <jsp-property-tag> in web.xml (DD)to enable it,but still it is not being enabled.
So help me so that I can run EL in my JSP page.
BR//
Anubhav Gulati
# 1
Example JSP used as default page on a new Web Application project on Netbeans:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>JSP Page</h1>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
</body>
</html>
Also, add the jstl.jar and standard.jar jars to your WEB-INF/lib application directory.
# 2
Hi,Thanks for giving response,but still I am not able to run,I am using tomcat,and name of my program is jstltag1,but it's showing the error(HTTP Status 404) resource is not available,so where could be the problem.waiting for response.BR//Anubhav Gulati
# 3
Hi,
I have found that EL is new feature,and for this jsp version should be 2.0 but in my machine I have jsp version 1.2,so i think this is the problem why EL is not runnning on my machine.So could you please tell what I have to do to get this new version 2.0 of jsp,for this the 2 jar files get changed or something different.
Waiting for reply.
BR//
Anubhav Gulati
# 4
Upgrade your container ( example , if you are using Tomcat switch to Tomcat 5.5.x , if you want JSP2.0 and Servlet 2.4 , the JAR files are located under Tomcat's lib folder)
Also change your web.xml web-app tag, it should be that of Servlet 2.4 version.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you want JSP 2.1 and Servlet 2.5 then upgrade to Tomcat 6.x -
JSP 2.1 supports Unified EL, which is the next version of the traditional EL .
Unified EL works with both JSF 1.2 and JSP 2.1
# 5
Thanks for responding.But can u tell me from where I can free download tomcat 6.0,and what to write in web-app tag of servlet 2.4.BR//Anubhav Gulati
# 6
Google is your friend, so search on Google for Tomcat 6.0 and it will show you were you can get it from.
Take a look at the Apache Tomcat Version Chart here:
http://tomcat.apache.org/whichversion.html
Servlet 2.5/ JSP 2.1 -- Tomcat 6.0.10
Servlet 2.4/ JSP 2.0 -- Tomcat 5.5.23
Since you want Servlet 2.4 and JSP 2.0 which are required for JSTL 1.1, you could get Tomcat 5.5.x , instead of Tomcat 6.0.x
Although I don't know if Tomcat 6 is backwards compatible with Servlet 2.4 and JSP 2.0 , if it is then it's cool to get Tomcat 6.x
--
web.xml - Servlet 2.4 Version
--
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
</web-app>
--
web.xml Servlet 2.5 version is different
--
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
</web-app>