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

When i run the following simple code in  eclipse with   Apache Tomcat/7.0.26, Sevlet Version : 3.0,  JSP Version : 2.1 and  Java Version : 1.6.0_20

I got the  error “According to TLD or attribute directive in tag file, attribute value does not accept any expressions” .  If you get the same error , making  the below changes in the JSP  will save your day.

 Replace the line       <%@ taglib uri=’http://java.sun.com/jstl/core’ prefix=’c’% >   in the JSP  with    either

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

         <%@ taglib uri=’http://java.sun.com/jstl/core_rt’ prefix=’c’% >  

Let us see how the problem is solved .

Tag library descriptor (TLD)  files play major  role  because it  maps the tag and the tag handler class. You need to just include taglib directive in the JSP with absolute URI  mentioned in the tld file  so that the page can use the tags defined in a tag library. TLD file has various attributes to be passed to the tag handler class.  One of the attribute is value  which accepts value or the expression to be evaluated depending upon the node rtexprvalue (run time expression value)   value  as given below   <rtexprvalue>true </rtexprvalue>. If it is true , it accepts , the expression , otherwise not.  Now let us see the reason.

Suppose you are using jstl-1.2.jar and standard-1.1.2.jar, it has three .tld files for each library
For example, core library  has  three tld files  (c-1_0.tld, c-1_0-rt.tld ,  c.tld ) ,  format library has three tld files that are  fmt-1_0.tld ,   fmt-1_0-rt.tld ,  fmt.tld .  Similary xml ,  sql library have three tld files each, functions library has only one tld file.  You can see the tld files in the META-INF folder when you extract the jar files.

Now let us take the core library tld files c-1_0.tld ,   c-1_0-rt.tld   ,  c.tld. Each tld files have some changes. I have noticed  some of the changes .  Please go through the tld files given below which are related to our problem

According to the old  c-1_0.tld , some of the specifications are as follows
1.  attribute value does not accept any runtime expressions(rt)

2. it uses DTD to define the  struture  of XML document

3 .it uses the  encoding  format “ISO-8859-1”

4. URI to  identify   the tag library descriptor (TLD) file uniquely  is   http://java.sun.com/jstl/core,

5. JSTL version 1.0   , 6. required JSP version  is 1.2

Part of the tld file is given below

 

According to the   c-1_0-rt.tld file ,
1.  attribute value accepts runtime expressions(rt) 

2. URI to  identify   the tag library descriptor (TLD) file is   http://java.sun.com/jstl/core_rt ,

3.  JSTL version 1.0

4.  required JSP version  is 1.2


Part of the tld file is given below

 


According to the  latest   c.tld   file ,
1.  attribute value accepts any runtime expressions(rt)

2. it uses XSD (XML Schema)   to define the  struture  of XML document

3. it uses the  encoding  format “UTF-8”

4. URI to  identify   the tag library descriptor (TLD) file   is   http://java.sun.com/jsp/jstl/core ,

5. data type is fixed for most of the variables which ensures the  type safe  , 5. JSTL version 1.1,

6.  required JSP version is 2.0

Part of the tld file is given below

 

Now you have to decide which URI you have to use with taglib directive .

Summary to remember:

JSTL 1.0  is compatible with  Servlet 2.3,  JSP 1.2 , suitable URI is  http://java.sun.com/jstl/core . To accept RT expression ,  use  http://java.sun.com/jstl/core_rt
JSTL 1.1  is compatible with Servlet 2.4, JSP 2.0, suitable URI is  http://java.sun.com/jsp/jstl/core.

To work with old .tld file , use the URI   http://java.sun.com/jstl/core_rt
JSTL 1.2  is compatible with  Servlet 2.5 onwards, JSP 2.1, suitable URI is  http://java.sun.com/jsp/jstl/core. Still you have chance to work with old .tld file  using the URI    http://java.sun.com/jstl/core_rt

 

You may also like

Leave a Reply