Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL functions

 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,
Does Tomcat 6.x support EL functions..
I am trying to implement very simple example found in the url below
http://java.boot.by/wcd-guide/ch07s04.html

it's not working for me...Here is my error´┐Ż
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
MyELFunctions cannot be resolved to a type


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
MyELFunctions cannot be resolved to a type


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:329)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your deployment descriptor and match this



If Its correct then post your code.
 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ali,
Nope , that didn't helped either.
see below.
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app id="WebApp_ID" 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 [url=http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">]http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">[/url]
<taglib>
<taglib-uri>http://www.server.com/example-taglib</taglib-uri>
<taglib-location>/WEB-INF/example-taglib.tld</taglib-location>
</taglib>
<resource-ref>
<description>junk Connection Pooling</description>
<res-ref-name>jdbc/junk</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>Test1</servlet-name>
<servlet-class>test.Test1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test1</servlet-name>
<url-pattern>/Test1</url-pattern>
</servlet-mapping>
</web-app>
example-taglib.tld
<?xml version="1.0" encoding="UTF-8"?>
<taglib 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
web-jsptaglibrary_2_0.xsd" version="2.0">
<tlib-version>1.0</tlib-version>
<function>
<description>Concatenates two strings</description>
<name>concat</name>
<function-class>MyELFunctions</function-class>
<function-signature>
java.lang.String concat(java.lang.String, java.lang.String)
</function-signature>
</function>
</taglib>
MyELFunctions.java (compiles fine. very simple)
public class MyELFunctions {
public static String concat(String str1, String str2) {
return str1 + str2;
}

}

and the error


org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
MyELFunctions cannot be resolved to a type


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
MyELFunctions cannot be resolved to a type


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:329)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about JSP Code
 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for looking into this for me.
it's exactly same as example i am trying to test foud at
http://java.boot.by/wcd-guide/ch07s04.html
only thing different in mine is that MyELFunctions class is inside classes directory instead of package.
<%@ taglib prefix="my" uri="http://www.server.com/example-taglib" %>
<html>
<head><title>EL Function example</title></head>
<body>
str1 is : ${param["str1"]} <br>
str2 is : ${param["str2"]} <br>
concatenated : ${my:concat(param["str1"], param["str2"])}
</body>
</html>
 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, if i use plain old jsp like this
it works But EL
<%
out.print(MyELFunctions.concat("aaaasdf","asdfzzz"));
%>
EL way does not work...
<%@ taglib uri="http://www.server.com/example-taglib" prefix="myxxx" %>
${param["str1"]} <br>
${param["str2"]} <br>
${myxxx:concat(param["str1asdf"], param["str2asd"])}
WHY WHY WHY
 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
finally I got it to work and hopefully this will help save many hours.

THIS WORKS
${myxxx:concat("firstString","secondString")}

THIS DOES NOT WORK
${param["str1"]}
${param["str2"]}
${myxxx:concat(param["str1"], param["str2"])}
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it will work


or use

[ January 19, 2007: Message edited by: Ali Gohar ]
 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem was that i needed sit down and learn EL syntax before trying out there things.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic