Tuesday, December 12, 2006

According to TLD or attribute directive in tag file, attribute value does not accept any expressions

Keywords:
Compile JSP tomcat JSTL error "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"

Problem:
Compile error from tomcat when it encounters a JSP: "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"

Solution:
For some reason the JSP is using the 1.2 JSP (and 1.0 JSTL) and EL expressions aren't understood. There's a lot of hits on the web for this but in summary there are 2 important things to do to ensure you're getting the right version of the spec:
  1. Reference the correct servlet specification in your deployment descriptor:
    <?xml version="1.0"?>
    <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">
  2. Reference the correct JSTL uri in your JSP:
    change
    <%@ taglib uri='http://java.sun.com/jstl/core' prefix='c'%>

    to
    <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>

Notes:


What Specification goes with what?
Web-app(deployment schema)2.32.42.5
http://java.sun.com/dtd/web-app_2_3.dtdhttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsdhttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
Servlet2.32.42.5
JSP1.22.02.1
JSTL(core uri reference)1.01.11.2
http://java.sun.com/jstl/corehttp://java.sun.com/jsp/jstl/corehttp://java.sun.com/jsp/jstl/core
Tomcat4.x5.x6.x
WebSphere5.x6.x7.x (?)

100 comments:

  1. Thank you very much! This hint was very helpful for me!!

    ReplyDelete
  2. OMG ... two days lost Tnx!

    ReplyDelete
  3. This help me too, thank you

    ReplyDelete
  4. Saved my day! Thanks a lot.

    ReplyDelete
  5. Saved my day! Thanks a lot.

    ReplyDelete
  6. Danke. Habe 1 Tag vergeblich den Fehler gesucht.

    ReplyDelete
  7. Thanks a bunch!!! Saved my bacon!

    ReplyDelete
  8. Thank you!! It drove me to dispair...

    ReplyDelete
  9. Thank u very Much

    ReplyDelete
  10. This site Helps Me thank u very Much

    ReplyDelete
  11. Thanks dude!!! 2 hours left just for uri="http://java.sun.com/jsp/jstl/core" hahahaha

    ReplyDelete
  12. Great. Saved my time too.

    ReplyDelete
  13. Great. Saved my time too.

    ReplyDelete
  14. Another thank you from me. I only besucht den Fehler for four hours, but this was a real lifesaver.

    ReplyDelete
  15. Brilliant, you saved me a lot of pain!

    ReplyDelete
  16. This is great!!!
    Thanks a lot.
    This really helped me a lot.

    ReplyDelete
  17. This error also happens if you include the tag libraries twice.

    I had the same problem with one include which I forgot to delete that had the directives for including the libraries.

    ReplyDelete
  18. Thanx alot i spent half day to find out solution but didn,t get ur trick worked for me it saves lot of time thanx again

    ReplyDelete
  19. I have wasted 2 days to find the solution for this. Thanks a lot.

    ReplyDelete
  20. thanx for giving solutions for this type of error

    ReplyDelete
  21. thanks
    it's work for me
    - Joshua

    ReplyDelete
  22. Thank you very much!!!

    ReplyDelete
  23. Thanks buddy. I have already spent 6 hours wasting. Thanks a lot again.

    ReplyDelete
  24. Heck yea, this totally solved my problem. Thanks buddy!

    ReplyDelete
  25. G'day mate.
    Saved my day!
    Thanks!

    ReplyDelete
  26. Cheers mate. Thanks for your help.
    /Andy

    ReplyDelete
  27. The Force will be with you. :)

    ReplyDelete
  28. Thanks a lot!!!

    ReplyDelete
  29. That was very helpful. Thank you.

    ReplyDelete
  30. Thank you very much - this was exactly the answer I was looking for!

    ReplyDelete
  31. That's works! Thanks!

    ReplyDelete
  32. Thanks

    very helpful infomations

    ReplyDelete
  33. thanks very much! i could avoid a ton of frustration.

    ReplyDelete
  34. thx very much

    nandx - indonesia

    ReplyDelete
  35. Yes, that helped me also! You would think that servlet containers/jsp compilers could be a little more helpful when reporting these sorts of issues.

    Thanks for publishing!

    ReplyDelete
  36. Yet another thank you!

    ReplyDelete
  37. thank you. It helped me to fix.

    ReplyDelete
  38. thank you for the really really useful hint

    ReplyDelete
  39. I highly appreciate your post. It was very helpful.

    ReplyDelete
  40. Thank you so much! great work!

    ReplyDelete
  41. Live long and prosper, my friend.

    ReplyDelete
  42. Great effort i appreciate ur effort

    ReplyDelete
  43. You saved me a lot of time! Thanks a lot from germany!

    ReplyDelete
  44. Thank you for writing that post.

    ReplyDelete
  45. Extemely helpful. Saved my day.

    ReplyDelete
  46. Thank you, I was having this same problem with JSTL Format.

    ReplyDelete
  47. thanks a liot it really helped..awesome

    ReplyDelete
  48. thanku very much

    ReplyDelete
  49. Hi Buddy, Thanks a lot. This information was very useful.

    ReplyDelete
  50. Thanks.. it helped me a lot

    ReplyDelete
  51. hey now we use web-app 2.5.
    there we can use

    xml version="1.0" encoding="UTF-8"
    web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5"

    in the web.xml as the schema and we can use the taglib

    @ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
    @ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
    in this way.This is also working.....

    and please put the relevant greater and lesser than marks in appropriate places.

    ReplyDelete
  52. hey please use the jstl-1.2.jar.
    sorry forgot to mention in the previous one....
    download jar files @ http://www.jarfinder.com/

    ReplyDelete
  53. It worked ! Just changed taglib uri value and it worked. Thanks a lot.

    ReplyDelete
  54. Thank you very much. its very useful for me. Thank you a lot.

    ReplyDelete
  55. I can't believe it took me half a day to fix this. Thanks for this post. The problem with tomcat/spring/jstl stuff is that there're so many outdated blogs/tips/tutorial out there that're totally misleading.

    ReplyDelete
  56. Thanks a million!

    ReplyDelete
  57. Thanks very much!!

    ReplyDelete
  58. thanx a Lot man !! :)

    ReplyDelete
  59. Thanks.Your hints helped me to deploy my application successfully

    ReplyDelete
  60. Gr8 seriousli .... helped me save a lot of time...

    ReplyDelete
  61. Danke schön! Thank you!

    ReplyDelete
  62. Thanksss many many times

    ReplyDelete
  63. Thank you! You saved my time...

    ReplyDelete
  64. thanks a lot....it worked for me

    ReplyDelete
  65. Thankyou very much. This saved my time.

    ReplyDelete
  66. thank you for http://java.sun.com/jsp/jstl/core

    ReplyDelete
  67. Thank you...It was the link problem.

    ReplyDelete
  68. Thank u. This is a simple solution for my big problem.

    ReplyDelete
  69. Hey this is really helpful thank you very very much ... great

    ReplyDelete
  70. Excellent Solution, Tanks a lot for your correct solution.
    Regards
    Muthuvel.P

    ReplyDelete
  71. thank you very much for the solution.

    ReplyDelete
  72. Can't fu...g believe...
    1 day lost for this.. many thanks. man

    ReplyDelete
  73. it worksssss...nice... :)

    ReplyDelete
  74. i did this
    <%@ page isELIgnored ="false" %>

    <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>

    i just used these and web xml was still at 2.3 spec and
    lib had to jars
    jstl.jar
    standard.jar

    but i guess the tag lib decl modification helped a ton
    thank you so much

    ReplyDelete
  75. screwed for 2 days. finally got it. very useful post

    ReplyDelete
  76. thanks so much .saved my lot of time.
    very useful information

    ReplyDelete
  77. Very useful information.
    Should've googled before...

    ReplyDelete
  78. Thank you very much.. it help me to save my job.

    ReplyDelete
  79. Thanks a lot for this information. This helped me a lot.

    ReplyDelete
  80. Thank you very very much !!!

    ReplyDelete
  81. wasted 2 days to fix this... This post helped me alott.. thanks...

    ReplyDelete
  82. I owe you a beer!

    ReplyDelete
  83. Thanx for the information,it helps me al lot......

    ReplyDelete
  84. It is very useful. It helps me too. Thank You very much

    ReplyDelete
  85. it solved ma problem .... thanks

    ReplyDelete
  86. Thanks a lot... You saved me!

    ReplyDelete
  87. Spot on! Thank you very much for this!

    Such a simple thing, but easy to miss!

    ReplyDelete
  88. Thanks for your gr8 help.
    Really appreciable.

    ReplyDelete
  89. thank you very much.i was able to solve the problem.
    i am using netbeans 7.0 my
    web-app version 3.0 .hence i have to go for jstl 1.1 or higher,when i add it to my project solved the problem .once agin thank you very much.sir.

    ReplyDelete
  90. thanks your tutorial helped me lot to figure out the issue.once agina thnak you

    ReplyDelete