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

JSP custom tag unable to pass dynamic value

 
Amit Kohli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing problem while passing dynamic values in my custom tag.
I have created one tag which is retrieving some data based on passed-in values. It is working fine with static values like in my jsp if I use
<xyz:GetValues brandCode='01' locationType="DEL" currencyCode="GBP"/>
i.e. in my tag I am passing 3 values and getting some results.

But when I am using same tag with dynamic values like

<xyz:GetValues brandCode='<%=code%>' locationType="DEL" currencyCode="GBP"/>

It is showing JasperException (i.e. According to TLD or attribute directive in tag file, attribute brandCode does not accept any expressions).

Following are my configurations for this project:

1. I am using struts2.0 and tomcat6.0.
2. In my tld(for this customized tag), I have mentioned
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>DemoTags</shortname>
<uri>http://www.abc.com</uri>
<info>Demo Tags Library</info>

3. My web.xml contains
<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">

Please suggest.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest changing your TLD so the tag allows expressions; exactly what the error message says.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scriptlet expressions? In 2010?

Why are you not using the EL?
 
Amit Kohli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<cut value='${code}'/> -- is working fine but facing problem while passing it as parameter in custom Tag.

I have tried running same code using EL expression but getting same error.

<xyz:GetValues brandCode="${code}" locationType="DEL" currencyCode="GBP"/>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you fixed your TLD yet?
 
Amit Kohli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David please suggest what changes are required in TLD to fix this issue.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably something about allowing expressions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic