aspose file tools*
The moose likes JSP and the fly likes Exception when using JSTL <c:out> with EL expressions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Exception when using JSTL <c:out> with EL expressions" Watch "Exception when using JSTL <c:out> with EL expressions" New topic
Author

Exception when using JSTL <c:out> with EL expressions

Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 111

hi

I am using an expression language within the value attribute of <c:out> but i get the following exception.The following is my <taglib> declaration in the JSP
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

the <c:out> that i used is
<c:out value="${musicMap.Ambient}" escapeXml="true"></c:out>.


I have put the .tld files inside a directory called 'tld' under WEB-INF.I have also added information about the taglib in web.xml.
The jstl.jar and standard.jar are inside the 'lib' directory in the WEB-INF.

Now i get the following exception.

org.apache.jasper.JasperException: /files/cout.jsp(20,0) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1174)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:821)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1736)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:183)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


I would be thankful if anybody can help me out on this.


Thanks,
Deepak.


Regards,
Deepak

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

In the future, please be sure to check the "disable similes" checkbox when posting code. I have adjusted your post for you.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65


That's the URI for the older JSTL 1.0 version. Surely not the one you intended to use?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Deepaks Deshpande wrote:
I have put the .tld files inside a directory called 'tld' under WEB-INF.I have also added information about the taglib in web.xml.

Wrong and wrong. Remove the TLD files and remove any declarations in the web.xml. They are not necessary and are likely just to gum up the works.

Once you are using the correct URI for the JSTL, the container will automatically find the TLD files in the jar files without all that goop.
Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 111

I have fixed the exception. I changed the <taglib> declaration in the JSP from
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> to

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>.Now the code works fine.


Thanks,
Deepak
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Why do you bother to post here if you are going to ignore the responses?

That's not correct. You are still using the JSTL 1.0.

While it may appear to be working, you will come across other problems if you do not fix it correctly.

What version of JSTL are you intending to use? Unless you are still using JSP 1.2, you are using the wrong version of the JSTL!
Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 111

I am using eclipse and if i change the <taglib>'s uri declaration from <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> to this <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> I am getting an exception saying the usi cannot be resolved. I also tried removing the .tld files from WEB-INF directory but again got the same exception.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Again, what version of JSP are you using?

You may have old versions of the jar files.
Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 111

I downloaded the jstl from apache site it is jakarta-taglib-1.1.2 and i am using jre 6 and javaee 5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

If you have the JSTL 1.1, then you need to be using the JSTL 1.1 URIs.

If eclipse (I hate IDEs) is complaining, find out why.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception when using JSTL <c:out> with EL expressions
 
Similar Threads
New to JSP
Regarding JSTL Core
JSTL installation
getting variable value
Problem with jstl