Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

c:if test doesnt like el?  RSS feed

 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code that eclipse is complianing about



the error message is "invalid attribute (test)"

As far as i know my app is all configured for EL.

I have set up my web.xml as per the FAQ page I found on another thread and added the below to the jsp
<%@ page isELIgnored="false" %>

Anyone know what's wrong?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What eclipse says is moot. Does it work?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Wa wrote: and added the below to the jsp

Remove it. If your web app is set up properly, extra goop on the pages is not required.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats what I thought.

Even without it, it still does not work
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read ItDoesntWorkIsUseless. What does it do?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Please read ItDoesntWorkIsUseless. What does it do?


I have seen that page before. It still does the same thing. I still get the message "invalid attribute(test)"
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what you get when you run it outside of the IDE?
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your c:if doesnt end with a "/>" and ends with a ">" is it the same way in your JSP, or its a typo while posting? Are you getting any exception during runtime?

If yes, post the exception on this forum

Show us your taglib directive for the "c" tag library, if possible post the complete JSP.

Make sure you have the standard.jar and jstl.jar in your classpath and use the following in the uri of the taglib directive

http://java.sun.com/jsp/jstl/core


 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer bear:

I get the following when run

16:36:11,701 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /saved.jsp(12,1) According to TLD or attribute directive in tag file, attribute test does not accept any expressions
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1172)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:819)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer Amol:

I appear to have all the jars and the jsp is below:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
16:36:11,701 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /saved.jsp(12,1) According to TLD or attribute directive in tag file, attribute test does not accept any expressions

This is usually indicative of a version mismatch in the configuration.

And indeed, your JSP shows that you are using the URI for JSTL 1.0. Are you using an ancient version of Tomcat? Why would you be using such an old version of the JSTL?

Amol posted the proper URI for modern JSTL.

Proper set up of the JSTL is outlined in the JSP FAQ -- have you worked through that?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amol Nayak wrote:your c:if doesnt end with a "/>" and ends with a ">"

As it should. Obviously there's a closing tag that he omitted in his post. What use would a self-closing <c:if> tag without a var attribute be?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. Thanks. I had copied and pasted that line from some reference page I found googling. I will sort it out.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP FAQ should help you out.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All working!
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using JSTL 1.1 and above using the uri http://java.sun.com/jsp/jstl/core should solve your problem.

If we look at the JSTL 1.0 TLD we have following for the attribute test



which does not allow runtime expressions.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Wa wrote:All working!

 
Jackie Li
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amol Nayak wrote:If you are using JSTL 1.1 and above using the uri http://java.sun.com/jsp/jstl/core should solve your problem.

If we look at the JSTL 1.0 TLD we have following for the attribute test



which does not allow runtime expressions.


as for jstl 1.1,

<attribute>
<description>
The test condition that determines whether or
not the body content should be processed.
</description>
<name>test</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
</attribute>

something to be careful abt, is that, jstl 1.0 and 1.1 got different uri for reference.
jstl 1.1 http://java.sun.com/jsp/jstl/core
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jackie Li wrote:something to be careful abt ...

Please use real words when posting to the forums. Abbreviations such as "abt" in place of "about" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please click this link ⇒ UseRealWords for more information.
 
Han Jie
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jackie Li wrote:
rtexprvalue indicates that "which does not allow runtime expressions."




i want to know that is jstl1.2 often be used at present?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Han Jie wrote:i want to know that is jstl1.2 often be used at present?

Of course. It's the most up-to-date version.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!