• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

doubt in EL

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the following code in the servlet

List ol=new ArrayList();
ol.add("hi");
ol.add("this");
RequestDispatcher rd=request.getRequestDispatcher("/jsp/testEL.jsp");
rd.forward(request,response);

and below code in the testEL.jsp

Values from the List are :${list["0"]} ${list["1"]}

but instead of getting the "hi this" as the out put i get "Values from the List are :${list["0"]} ${list["1"]}"
as the output the EL is not getting evaluated.

Is there any specific setup that i need to do for this to work.

Thanks
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please

add this in your servlet

request.setAttribute("list_name",list);

and in jsp

${list_name["0"]} or ${list_name[0]}
thanks & regards,
seetharaman
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or without touching the JSP :


Also make sure that you have configured everything properly. Check this FAQ.
[ May 12, 2008: Message edited by: Christophe Verre ]
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Sorry I have already put the code in my servlet i didnt show it here
request.setAttribute("list",ol);

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok then All left to do is to check the FAQ I have posted above. Make sure your web.xml is declared correctly.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rajaram,

add isELIgnored="false"(but it is default behaviour) in your page directory of jsp...whether you put isELIgnored="true" like anything?

thanks & regards,
seetharaman
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have added following entry in the web.xml file

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app 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"
version="2.4">

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remove the DOCTYPE and do an exact copy/paste of the one written here.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I deleted the DOC Type and did a exact copy paste of the specified contents like below

<?xml version="1.0" encoding="UTF-8"?>


<web-app 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"
version="2.4">

i tried it with both the tags specified in that link but still it didnt work
I am using tomcat Apache Tomcat/5.0.28 what could be the problem.

can any body give me a working web.xml file for EL
Thanks
[ May 12, 2008: Message edited by: raja ram ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remove also the first line Leave only the web-app tag.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I removed the first line and kept only <web-app> even then no results.

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the web.xml you now have ? And also please tell us where you put web.xml.

One more thing. You are using Tomcat 5.0.x. I recommend you to use Tomcat 5.5.x instead (although they are supposed to support the same spec...)
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My web.xml file contains the following


and web.xml file is present in this Path "C:\tomcat\webapps\learn\WEB-INF\web.xml"

Thanks
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you tell me which container and which version are you using?
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache Tomcat/5.0.28
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you have this line in you JSP ?
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check if you have proper jar files
standard.jar and jstl.jar

Regards
Sravanthi
 
Nishal Dsouza
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
install tomcat 5.5.26 or higher version it should work
 
Nishal Dsouza
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is because the container you are using does not support EL because it implements lower versions of JSP 2.0 specification.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have installed Apache Tomcat/5.5.26 now and tried with the same code but i am getting this exception

javax.servlet.ServletException: javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.jsp.testEL_jsp._jspService(testEL_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.scwcd.TestEl.doGet(TestEl.java:27)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

I have also copied jstl.jar and standard.jar files to my WEB-INF\lib folder
Thanks
 
S Sravs
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
even tough Tommcat has inbuilt el-api.jar file and jasper-el.jar files add into your lib path and restart
hope this solves your problem

Reagards
Sravanthi
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't see any obvious problem, so I wrote a quick test app to try it, using your servlet code, jsp, and web.xml. It all worked fine! it produced the output:


Since the exception seems to be coming from VariableResolver, I'd check your JSP code very carefully to make sure you don't have any typos that might be causing it to choke when it tries to evaluate "${list["0"]} ${list["1"]}".
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the java version you are using ? is it below 1.4 ?
 
Ranch Hand
Posts: 332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also delete \apache-tomcat-6.0.14\work\Catalina\localhost\YOUR_WEB_APP.
I had the same problem, read the faq, tried multiple web.xml's and all I got was ${1+1}, I deleted classes from tomcat's work dir and it started to work :-).

EDIT: I suggest to add this to FAQ.
[ May 14, 2008: Message edited by: John Stone ]
 
S Sravs
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sourabh Gandhi,
thanks for the link

Regards
Sravanthi
preparing for wcd 1.5
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Any solution to this problem all this time i am thinking that there is a problem with my code only but even the JSTL exapmles that come along with the tomcat is also giving the same error. what could be the reason
I am using
Apache Tomcat/5.5.26 conatiner and JDK 1.5

Thanks
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi raja ram,
have you tried what Vijaya said a few posts back? have you added el-api.jar file to your class-path. i think that file is available in tomcat 6 in the lib directory.(or if you have jboss available to you, its in the C:\JBoss\jboss-4.2.0.GA\server\default\lib directory ). Also add this to the classpath: servlet-api.jar and jsp-api.jar

Restart tomcat and try out the tomcat examples.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The problem is resolved i copied jsp-api.jar and servlet-api.jar in the
C:\tomcat\common\endorsed directory and restart the server it works fine now.

Thanks for all the replies
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic